multiple fields in side table when using left join
multiple fields in side table when using left join
volnistii11
Posts: 49Questions: 16Answers: 0
in Editor
If we take an example from this link https://editor.datatables.net/examples/simple/join.html and imagine that there is one more field in the sites table - the date. Now our request will look like this:
SELECT users.first_name,users.last_name,users.phone, sites.name, sites.date
FROM users
LEFT JOIN sites ON users.site = sites.id`
how to change this in js and server script?
This question has an accepted answers - jump to answer
Answers
Assuming you are using the PHP libraries like in that example, then you would just add
sites.date
to the fields list - e.g.:Likewise, on the client-side just add a column that uses
columns.data
pointing to thesites.date
property that will now be in the JSON.Allan
for what it's worth, I like putting the joined fields after the join statement. it makes it more clear why you are even bringing in the second table, and if you need to test, you can comment out the join and the fields in one comment block
mvc .net version:
Nice way of doing it - thanks for sharing!
Allan
ty, and in the editor's fields, how to write it?
On the client-side? You typically would only have a single field in the Editor form which defined the value of the linked row (i.e. the primary key). If you need to edit the data in the linked table, consider using an approach like this.
Allan