Ben sorun bir sorgu oluşturma yaşıyorum. Ben 3 farklı sorgularda istediğimi yapabilirim.
SELECT id FROM table1 WHERE url LIKE '%/$downloadfile'
put that in $url_id
SELECT item_id FROM table2 WHERE rel_id = '$url_id'"
put that in $item_id
SELECT rel_id FROM table2 WHERE rel_id = '$item_id' AND field_id = '42'"
put that in $user_id
Ama üzerinde örnekler okuma katılır ve iç ben daha şık bir yolu olduğunu düşünüyorum katıldı. Ben daha iyi bir sorgu yazma etrafında beynimi sarın olamaz (ama istiyorum) Ben gitmeli nasıl tanımlayabiliriz:
table1 fields: id, url
table2 fields item_id, rel_id, field_id
I know the last part of table1.url (LIKE '%/$filename') with that I select table1.id. table1.id is equal to one entry in table2.rel_id. So get that and select the table2.item_id. In table2 there is another entry which has the same table2.item_id and it will have a table2.field_id = '42' And finally the value I need is the table2.rel_id where the table2.field_id was 42. I will fetch that value and put it in $user_id
Bu kullanarak bir sorgu ile yapılabilir katıldı / iç birleşimler?