catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

What about subqueries? #252

Closed icetomcat closed 3 years ago

icetomcat commented 9 years ago
                            case 'array':

                                if (
                                        isset($value["table"]) &&
                                        isset($value["join"]) &&
                                        isset($value["column"]) &&
                                        isset($value["where"])
                                )
                                {
                                    $wheres[] = $column . ' NOT IN (' . $this->selectContext($value["table"], $value["join"], $value["column"], $value["where"]) . ')';
                                }
                                else
                                {
                                    $wheres[] = $column . ' NOT IN (' . $this->arrayQuote($value) . ')';
                                }

                                break;

If i want to find all news without comments, I should use 2 queries in one, "select * from news WHERE news.id not in (select news_id from comments ...) ..."

sorry for my english, php and sql :)

izshreyansh commented 8 years ago

I don't think there's any other way to do this other than, executing raw query see this: http://medoo.in/api/query