danz67
asked on
MYSQL - Query Select
hi,
I have 2 tables
TABLE_NAME = VENDUTI
FIELDS:
IDARTICOLO: INTEGER
QUANTITA: INTEGER
TABLE_NAME = ARTICOLI
FIELDS:
ID: INTEGER
DESCRIZIONE: VARCHAR
I need a query that makes me see all the records in the table articoli that are not present in the table
venduti
I have 2 tables
TABLE_NAME = VENDUTI
FIELDS:
IDARTICOLO: INTEGER
QUANTITA: INTEGER
TABLE_NAME = ARTICOLI
FIELDS:
ID: INTEGER
DESCRIZIONE: VARCHAR
I need a query that makes me see all the records in the table articoli that are not present in the table
venduti
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The first one is easy for understanding but it's slowy than second.
ASKER
SELECT A.*
FROM VENDUTI A
LEFT OUTER JOIN ARTICOLI B OB A.IDARTICOLO = B.ID
WHERE B.ID IS NULL
generate error
FROM VENDUTI A
LEFT OUTER JOIN ARTICOLI B OB A.IDARTICOLO = B.ID
WHERE B.ID IS NULL
generate error
ASKER
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OB A.IDARTICOLO = B.ID
WHERE B.ID IS NULL' at line 3
WHERE B.ID IS NULL' at line 3
>> generate error
What is the error?
What is the error?
ASKER
The error is:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OB A.IDARTICOLO = B.ID
WHERE B.ID IS NULL' at line 3
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OB A.IDARTICOLO = B.ID
WHERE B.ID IS NULL' at line 3
Simple mistake. 'OB' should be renamed to 'ON' !!
SELECT A.*
FROM VENDUTI A
LEFT OUTER JOIN ARTICOLI B ON A.IDARTICOLO = B.ID
WHERE B.ID IS NULL
Hi
Use this querys..
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUTI ,ARTICOLI WHERE ARTICOLI.ID = VENDUTI.IDARTICOLO
OR
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUT JOIN ARTICOLI ON( ARTICOLI .IDARTICOLO = VENDUT .ID)
OR
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUT LEFT OUTER JOIN ARTICOLI ON( ARTICOLI .IDARTICOLO = VENDUT .ID)
OR
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUT INNER JOIN ARTICOLI ON( ARTICOLI .IDARTICOLO = VENDUT .ID)
any one join query will satisfy u r needs
by
kumaresan
Use this querys..
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUTI ,ARTICOLI WHERE ARTICOLI.ID = VENDUTI.IDARTICOLO
OR
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUT JOIN ARTICOLI ON( ARTICOLI .IDARTICOLO = VENDUT .ID)
OR
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUT LEFT OUTER JOIN ARTICOLI ON( ARTICOLI .IDARTICOLO = VENDUT .ID)
OR
SELECT VENDUTI.*,ARTICOLI .*
FROM VENDUT INNER JOIN ARTICOLI ON( ARTICOLI .IDARTICOLO = VENDUT .ID)
any one join query will satisfy u r needs
by
kumaresan