How to do this query?

Posted by Damiano on Stack Overflow See other posts from Stack Overflow or by Damiano
Published on 2010-05-16T11:06:09Z Indexed on 2010/05/16 11:10 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

Hello everybody!

I have a mysql table with these columns:

  • ID (auto-increment)
  • ID_BOOK (int)
  • PRICE (double)
  • DATA (date)

I know two ID_BOOK values, example, 1 and 2.

QUERY:

I have to extract all the PRICE (of the ID_BOOK=1 and ID_BOOK=2) where DATA is the same!

Table example:

1  1  10.00  2010-05-16

2  1  11.00  2010-05-15

3  1  12.00  2010-05-14

4  2  18.00  2010-05-16

5  2  11.50  2010-05-15

Result example:

1  1  10.00  2010-05-16

4  2  18.00  2010-05-16

2  1  11.00  2010-05-15 

5  2  11.50  2010-05-15

ID_BOOK=2 hasn't 2010-05-14 so i jump it.

Thank you so much!

© Stack Overflow or respective owner

Related posts about select

Related posts about sql