Select one value, not the other
On 2015-04-29 12:20 AM, Olivier Nicole wrote:
SELECT * FROM table WHERE item_number=1;
Sorry if my question was not clear: what I am looking for is:
SELECT * FROM table WHERE data_value=1 AND "there is not any reccord with
the same item_number and data_value=2"
Assuming a table named t ...
One way, an exclusion join:
from t a
left join t b on a.item_number=b.item_number and b.data_value=2
where a.data_value=1 and b.item_number is null;
Another way, with a semi-join:
from t a
and not exists (select data_value from t b where
b.item_number=a.item_number and data_value=2);
On Wed, April 29, 2015 06:30, Olivier Nicole wrote:
I am sure that it is feasible with MySQl, and I am sure that's a newbie
question, but my SQL skills are limited...
I have a table where each record is made of one item_number and one
If one item has several values, there are several records with the same
item_number and a different data_value.
What is the command to select all the records where an item_number has
the data 1 but not the data 2?
Thanks in advance,
+66 8701 33224
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.