Hi, I have been beating my brains on this query and can't get it to work.
tblItem has the field with id as the primary key
id name
1 A
2 B
3 C
tblCustom has the field (both field are foreign keys)
itemid sideid
1 15
1 17
2 15
3 16
tblSide has the field with the id as the primary key
id name
15 AA
16 BB
17 CC
What I'm trying to do is to select all the fields in tblSide where the itemid in tblCustom doesn't equal to 1.
The result I want for tblSide is this:
id name
16 BB
What I'm getting instead is
id name
15 AA
16 BB
the reason why 15 is showing up is because in tblCustom, 2 has 15, it shouldn't show up because 1 has value 15 too. Here's my SQL statement.
SELECT tblSide.id, tblside.name tblcustom.itemid, tblcustom.sideid
FROM tblside LEFT JOIN tblcustom on tblside.id = tblcustom.sideid
WHERE tblcustom.itemid <> 1 or tblcustom.itemid is null;
does anyone know what I am doing wrong? Thanks in advance for your input.
tblItem has the field with id as the primary key
id name
1 A
2 B
3 C
tblCustom has the field (both field are foreign keys)
itemid sideid
1 15
1 17
2 15
3 16
tblSide has the field with the id as the primary key
id name
15 AA
16 BB
17 CC
What I'm trying to do is to select all the fields in tblSide where the itemid in tblCustom doesn't equal to 1.
The result I want for tblSide is this:
id name
16 BB
What I'm getting instead is
id name
15 AA
16 BB
the reason why 15 is showing up is because in tblCustom, 2 has 15, it shouldn't show up because 1 has value 15 too. Here's my SQL statement.
SELECT tblSide.id, tblside.name tblcustom.itemid, tblcustom.sideid
FROM tblside LEFT JOIN tblcustom on tblside.id = tblcustom.sideid
WHERE tblcustom.itemid <> 1 or tblcustom.itemid is null;
does anyone know what I am doing wrong? Thanks in advance for your input.