I am getting the following message when trying to get a specific value in my query
"The specified field could refer to more than one table"
It is pretty clear that I am trying to search something present in more than one table, but how to do this right?
now I have the following code:
SELECT Table1.CustomerId, Table1.Address,
Table2.CustomerId, Table2.Telephone,
Table3.CustomerId, Table3.Notes
FROM (Table1 INNER JOIN Table2 ON Table1.CustomerId=TAble2.CustomerId)
INNER JOIN Table3 ON Table2.CustomerId=Table3.CustomerId
WHERE CustomerId = 0015
the last sentence is the problem... any ideas?
The error message is pretty clear, the field CustomerId in the WHERE clause WHERE CustomerId = 0015, is presented in both the two tables. You have to determine from which table you want to use it from; table1 or table2? for example:
SELECT Table1.CustomerId, Table1.Address,
Table2.CustomerId, Table2.Telephone,
Table3.CustomerId, Table3.Notes
FROM (Table1 INNER JOIN Table2 ON Table1.CustomerId=TAble2.CustomerId)
INNER JOIN Table3 ON Table2.CustomerId=Table3.CustomerId
WHERE table1.CustomerId = 0015
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With