« Return to Thread: struggling with select query

struggling with select query

by lee_m4c :: Rate this Message:

Reply to Author | View in Thread

Guys,

Below is a select query which I'm stuggling with, so I'd be grateful for any help you could give me.

select distinct TraderPersonalInfo.TraderID,PlatformMap.PlatformID from TraderPersonalInfo,Locations,PlatformMap,Platforms where (TraderPersonalInfo.TraderID = PlatformMap.TraderID) and (PlatformMap.PlatformID = Platforms.PlatformID) and PlatformMap.PlatformID = 2 or PlatformMap.PlatformID = 4;

The query above produces the following output:

+----------+------------+
| TraderID | PlatformID |
+----------+------------+
|        5 |          4 |
|        4 |          4 |
|        1 |          4 |
|        2 |          4 |
|        3 |          4 |
|        6 |          4 |
|        7 |          4 |
|        9 |          4 |
|       10 |          4 |
|       11 |          4 |
|       20 |          4 |
|       13 |          4 |
|       14 |          4 |
|       15 |          4 |
|       19 |          4 |
|       17 |          4 |
|       18 |          4 |
|       23 |          4 |
|       22 |          4 |
|       24 |          4 |
|        2 |          2 |
|        5 |          2 |
|        6 |          2 |
|        7 |          2 |
|        9 |          2 |
|       10 |          2 |
|       11 |          2 |
|       22 |          2 |
+----------+------------+

but, I only want to know which traders have platformID 2 *and* platformiID4.  In this case, only traderID 5 has both.  I can't seem to work out how to structure the statement so it works as a *AND*, not *OR* as above.

Any help would be greatly appreciated.

Cheers.

- Lee.

 « Return to Thread: struggling with select query