I've got two tables:
subjects: [id, ...]
categories: [subject.id, ...]
I want to select all subjects from table #1 without the entries in #2 (categories).
Any tips appreciated (:
best regards
INTO OUTFILE is the complement of LOAD DATA . Column values are written converted to the character set specified in the CHARACTER SET clause. If no such clause is present, values are dumped using the binary character set. In effect, there is no character set conversion.
MySQL stored functions only return a single scalar value. They cannot return result sets. Functions can be used in a scalar expression context. You can use a stored procedure to return a result set, but you can't use it in an expression.
The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set.
Sachin's already provided a correct answer, but you can do it with join syntax as well:
SELECT
subjects.*
FROM
subjects
LEFT OUTER JOIN
categories
ON
subjects.id = categories.subject_id
WHERE
categories.subject_id IS NULL
select * from subjects where id not in (select subject.id from categories )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With