English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am trying to do this in one query but not sure if it's possible or not.

Table A:
id, uId, pinId

Table B:
id, pinId, ccId

I am trying to grab all of the pinId for specified uId that do not show up in table B matching ccId specified.

So a SELECT pin FROM TABLEA WHERE uId = 2 gets me all of the pinId I need however, if one of the pin codes show up in Table B with the specified ccId I don't want it to return in the results.

2007-11-13 03:07:03 · 5 answers · asked by Jeff Lewis 2 in Computers & Internet Programming & Design

Am using mySQL 4 and MINUS seems to throw an error when using this statment:

SELECT pin FROM pincodes WHERE uId = 26 MINUS SELECT pin FROM pincodes_log WHERE cc_id = 22

2007-11-13 03:20:37 · update #1

5 answers

Search for "NOT IN" SQL query should give you what you want.

2007-11-13 03:31:12 · answer #1 · answered by Kasey C 7 · 0 0

i could accept as true with the previous answer...you have one in all 3 achieveable queries achieved reckoning on alternatives of the consumer from the drop-down 0 products chosen: execute question with out 'the place' standards a million merchandise chosen; execute question with 'the place someCol = ' 2+ products chosen: execute question with 'the place someCol IN '

2016-11-11 09:02:03 · answer #2 · answered by Anonymous · 0 0

SELECT a.pinId FROM tableA as a
OUTER JOIN tableB AS b ON a.pinId=b.pinId
WHERE a.uId = 2
AND b.pinId IS NULL

2007-11-13 04:53:38 · answer #3 · answered by wfinn 2 · 0 0

SELECT A.ID, A.UID, A.PINID, B.CCID
FROM PINCODES A

LEFT JOIN PINCODES_LOG B ON B.PINID = A.PINID

WHERE
A.UID = 26 AND
B.CCID NOT IN (, , ....)

2007-11-13 18:25:13 · answer #4 · answered by mel mel 2 · 0 0

use MINUS

select pinld FROM TABLEA
minus SELECT pinld from tableb

2007-11-13 03:10:30 · answer #5 · answered by BigRez 6 · 0 0

fedest.com, questions and answers