Hello. There is a database. Transport: id, transport and transport photo id, id_transport, photo. Some vehicles are without a photo, how to get all the records that have a photo?

  • Select * from ... where photo is not null ? - pavel
  • so photo and trasport in different tables - duddeniska

1 answer 1

It all depends on what type your photo field is. For example, if it is a string that stores the URL for a photo, then the request might be:

 SELECT DISTINCT * FROM transport_tbl WHERE transport_tbl.id = photo_tbl.id_transport AND photo_tbl.photo IS NOT NULL; 
  • It is strange that it does not work ( - duddeniska
  • @duddeniska, add in the post a description of the schema of both tables, so it will be more clear what you need - Ksenia
  • the problem is that it duplicates the recordings, since there can be several photos in one photo to one transport. (((what to do? - duddeniska
  • @duddeniska, add DISTINCT to the query (see the answer, it’s changed) - Ksenia
  • wow magic, what is DISTINCT go read))) - duddeniska