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
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
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
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_
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
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
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