2
When I run the following sql command I get an empty return, even if I indicate an id that is present in some rows of the table to be searched
SELECT e.data_request,
e.id_exchange,
e.data_exchange,
e.data_refound,
s.description AS status,
e.id_status,
t.description AS type,
u1.name AS requester,
u2.name AS substitute,
u3.name AS coord
FROM exchanges AS e
INNER JOIN status AS s ON e.id_status = s.id_status
INNER JOIN users AS u1 ON e.requester = u1.id_user
INNER JOIN users AS u2 ON e.substitute = u2.id_user
INNER JOIN users AS u3 ON e.id_coord = u3.id_user
INNER JOIN types AS t ON e.id_type = t.id_types
WHERE e.id_coord = 1
OR e.id_rh = 1
In the database the following data are registered:
Table users:
Table Exchanges:
and this is the return I get when running SQL:
In the WHERE clause, switch to WHERE (e. id_coord = 1 OR e.id_rh = 1)
– Jefferson Rudolf
received the same empty result making the change
– Felipe Schmidt
removes the Where clause and checks how many Row appears
– Ruben Borges Ramos
Ever tried to query only in the Exchanges table with Where to see if it returns, maybe it is the Inner’s that such using.
– Jefferson Rudolf
In your select you use the tables Exchanges, status, users and types but only showed the contents of the user and Exchanges tables. If the other tables do not matter it is that you actually want to use INNER JOIN in all of them or maybe you should use INNER JOIN only in these two and LEFT OUTER JOIN in the others?
– anonimo