Select one value, not the other

2015-04-29 Thread Peter Brawley
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 ... O

Re: AW: Select one valuebut not the other

2015-04-29 Thread Olivier Nicole
Axel, > Simply translated: > > select * from table t1 > where t1.data_value=1 > AND not exists(select * from table t2 >where t2.data_value=2 >and t2.item_number = t1.item_number) Yes, but with t1 and t2 the same table. best regards, Olivier > > > > Axel Die

Re: Select one valuebut not the other

2015-04-29 Thread Olivier Nicole
Lucio, >> I have a table where each record is made of one item_number and one >> data_value. > You do not have any other column ? In particular you do not have any > unique key record identifier ? All my tables have a column with a record > sequence number "seq int NOT NULL AUTO_INCREMENT" whic

Re: Select one valuebut not the other

2015-04-29 Thread Olivier Nicole
Thank you, > SELECT * FROM test > WHERE item_number in (SELECT item_number FROM test where data_value=1) > AND item_number not in (SELECT item_number FROM test where data_value = 2); That did it. Olivier > On Wed, April 29, 2015 07:20, Olivier Nicole wrote: >>> SELECT * FROM table WHERE item_

Re: Select one valuebut not the other

2015-04-29 Thread Lucio Chiappetti
On Wed, 29 Apr 2015, Olivier Nicole wrote: I have a table where each record is made of one item_number and one data_value. You do not have any other column ? In particular you do not have any unique key record identifier ? All my tables have a column with a record sequence number "seq int NO

AW: Select one valuebut not the other

2015-04-29 Thread Axel Diehl | GIP
Simply translated: select * from table t1 where t1.data_value=1 AND not exists(select * from table t2 where t2.data_value=2 and t2.item_number = t1.item_number) Axel Diehl __ GIP Exyr GmbH Hechtsheimer Str. 35-37 | 55131 Mainz Tel: +49 (0) 61

Re: Select one valuebut not the other

2015-04-29 Thread Mogens Melander
Right, Take a look at this one then: insert into test(item_number,data_value) values(1,1),(1,2),(1,3) ,(2,1),(2,3) ,(3,1),(3,2),(3,3) ,(4,1),(4,3); SELECT * FROM test WHERE item_number in (SELECT item_number FROM test where data_value=1) AND item_number not in (SELECT item_number FROM test where