Problem WHERE clause
Problem WHERE clause
Hi,
I use EDITOR Data Table and would like to know how to use the WHERE clause to get the result of the application SQL below
SELECT `gestion`.`date_entree`,
`gestion`.`date_sortie`,
`gestion`.`nbre_palette`,
`gestion`.`numero_bl`,
`gestion`.`transporteur`,
`gestion`.`achat_trs`,
`gestion`.`vente_trs`,
`regie`.`numero_bl_regie`,
`regie`.`date_regie`,
`regie`.`heure_regie`,
`regie`.`commentaire`
FROM `gestion`,
`regie`
WHERE `regie`.`numero_bl_regie`=`gestion`.`numero_bl`
Thanks a lot for your help.
This discussion has been closed.
Replies
You'd need to use the "complex" where options in Editor. For example:
The final parameter is the important one as it stops the value in the second parameter being bound.
Allan
Thanks for your response Allan,
But it's not work.
Erreur message is :
{"error":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'regie' in 'field list'","data":[]}
My code is correst ?
Thanks
Is the primary key in your
gestion
table calledregie
? Could you show me the SQL schema?Allan
Hi Allan,
Attached SQL plan.
This query works with the views in MySQL.
In summary:
gestion.numero_bl = mouvement.numero_bl_mouvement = regie.numero_bl_regie
Thanks
Super - thanks! Let me take a more detailed look over it than my phone allows for (travelling at the moment). Normal service resumes on Tuesday!
Allan
Could you try using:
for your constructor? I think the issue is that Editor doesn't prefix the primary key with the table name automatically. If you could let me know if that addresses the issue I will commit a change to fix that for future releases.
Thanks,
Allan
Hi Allan,
I just do the test with your code, it did not work.
Error Message :
DataTables warning: table id=example - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'gestion.regie' in 'field list'
Let's try:
Sorry - I copied and pasted your initialisation from above without full parsing the code in my head. There is no
regie
column in thegestion
column.Allan
Hi Allan,
Unfortunately, it does not find the table "regie"
Error Message :
DataTables warning: table id=example - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'regie.date_regie' in 'field list
There is no
leftJoin
statement in the above. You would need to add one to be able to read from two different tables. Documentation about how to do joins is available here.Allan