Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IN and NOT IN in WHERE clause #1005

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Vendict
Copy link

@Vendict Vendict commented Aug 21, 2021

But on right side use only RAW.

But on right side use only RAW.
@Vendict
Copy link
Author

Vendict commented Aug 22, 2021

But your solution don't solve like this
select * from table1 where id not in (select id2 from table2)

@phpseven
Copy link

My solution can also solve your problem, and it is more

#1003

$this->database->select(
"account",
"user_name",
[
Medoo::raw(" not in (select id2 from table2) "),
'LIMIT' => [20, 100],
"ORDER" => "user_id",
]
);

@Vendict
Copy link
Author

Vendict commented Aug 23, 2021

My solution can also solve your problem, and it is more

[
Medoo::raw(" not in (select id2 from table2) "),

need key on first row of this array:
PHP Fatal error: Uncaught TypeError: preg_match() expects parameter 2 to be string, object given in Medoo.php:859
You tested this ?

Please correct me, but on this :

$a = $database->select("company", '*', [
        'ID'=> Medoo::raw(" not in (select company_id from table2)"),
    ]);

I recive this SQL:

SELECT * FROM "company" WHERE "ID" = not in (select company_id from table2)

@phpseven
Copy link

phpseven commented Aug 23, 2021

My solution can also solve your problem, and it is more

[
Medoo::raw(" not in (select id2 from table2) "),

need key on first row of this array:
PHP Fatal error: Uncaught TypeError: preg_match() expects parameter 2 to be string, object given in Medoo.php:859
You tested this ?

Please correct me, but on this :

$a = $database->select("company", '*', [
        'ID'=> Medoo::raw(" not in (select company_id from table2)"),
    ]);

I recive this SQL:

SELECT * FROM "company" WHERE "ID" = not in (select company_id from table2)

Use the master branch in my repository to modify, and you have to write this

$a = $database->select("company", '*', [ Medoo::raw("<ID> not in (select company_id from table2)"), ]);

@Vendict
Copy link
Author

Vendict commented Aug 23, 2021

Use the master branch in my repository to modify, and you have to write this

thank you, I already used my solution in small project and try to share to another people to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants