Open faustfizz opened 1 year ago
Your code is almost correct, just another mistake to put a line of code, and get lost with your own Aliases of table.
Here i make the correct one, with inline comment and more verboses
for readability.
DataTables::create(db_connect()
// call table "users" with alias "u"
->table('user AS u'))
// select whatever you want, and call another field as join
// for better performance, better to call each collumn you want to fetch instead using wildcard
->select('u.*, p.nom AS name')
// join another table "prestataire" alias "p", with condition "p.id_prestataire = u.prestataire_id"
->join('prestataire AS p', 'p.id_prestataire = u.prestataire_id')
// put the where clause (don't forget to call it with prefix alias previously define)
->where('u.prestataire_id IS NOT NULL')
// rest of your code here ...
->make()
Let us know if it's working or not,
@irsyadulibad (nimbrung ngab)
Hi, thank you for replying, unfortunately it didn't work.
I think the select function is ignored, i cann't do a custom select when fields are conflicting.
i have table
user{ID, nom, prenom, prestataire_id}
andprestataire{ID, nom}
. I want to select with join but with no chance.I need help !