Skip to content

Add IN and NOT IN in WHERE clause#1005

Open
Vendict wants to merge 1 commit into
catfan:masterfrom
Vendict:master
Open

Add IN and NOT IN in WHERE clause#1005
Vendict wants to merge 1 commit into
catfan:masterfrom
Vendict:master

Conversation

@Vendict

@Vendict Vendict commented Aug 21, 2021

Copy link
Copy Markdown

But on right side use only RAW.

But on right side use only RAW.
@catfan

catfan commented Aug 22, 2021

Copy link
Copy Markdown
Owner

@Vendict

Vendict commented Aug 22, 2021

Copy link
Copy Markdown
Author

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

@phpseven

Copy link
Copy Markdown

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

Vendict commented Aug 23, 2021

Copy link
Copy Markdown
Author

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

phpseven commented Aug 23, 2021

Copy link
Copy Markdown

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

Vendict commented Aug 23, 2021

Copy link
Copy Markdown
Author

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