How to get empty column and null columns in laravel? - php
I have a column with null values in it and one is empty. Now I am trying to fetch both but it shows me an SQL syntax error. Please guide me on how can i fetch both empty and null columns.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,42450,42706,42962,43218,43474,43730,43994,44250,44506,44762,45018,45274,45' at line 1 (SQL: select token_id, email_state, email_event_time, created_at as email_created_at from email_tracker where transaction_id = 2856 and email_tracker.id IN (SELECT max(id) FROM email_tracker WHERE token_id IN (,,,,,,,42450,42706,42962,43218,43474,43730,43994,44250,44506,44762,45018,45274,45530,45793,46049,46305,46561,46817,47073,47329,47585,47841,48097,48353,48609,48880,49136,49392,49648,49904,50160,50700,50956,51212,51468,51724,51980,52236,52492,52748,53004,53260,53516) GROUP BY token_id) order by created_at desc)
$this->replies->where($field_name,'=', '')->orWhereNull($field_name);
Please guide me on what I am doing wrong here.
Any solution appreciated!
Related
How to using Eloquent groupBy and orderBy in laravel?
\App\Service::groupBy('type')->orderBy('id', 'DESC')->get(); I am using laravel 5.5.. Can help me for resolve this problem..? Error report "SQLSTATE[42000]: Syntax error or access violation: 1055 'db_name.tbl_name.id' isn't in GROUP BY (SQL: select * from tbl_name group by type order by id desc) "
If you got this error SQLSTATE[42000]: Syntax error or access violation: 1055 'tablename.fieldname' isn't in GROUP BY (SQL: select * from `tablename` group by `fieldname`) Then edit your database config file config/database.php In mysql array, set strict => false to disable MySQL's strict mode
When grouping in MySQL you can only work with either fields you are grouping by or fields used in aggregate functions of your select. Therefore orderBy('id', 'DESC') will do nothing in your case.
Database Error PDOException
I created my database tables and bake as usual with CakePHP 3 but when I point my browser to some link it give me this errors: Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS Users__contact person, Users.Phoneno AS Users__Phoneno, Users.email AS `U' at line 1 If you are using SQL keywords as table column names, you can enable identifier quoting for your database connection in config/app.php. SQL Query: SELECT Users.id AS `Users__id`, Users.name AS `Users__name`, Users.address AS `Users__address`, Users.contact person AS `Users__contact person`, Users.Phoneno AS `Users__Phoneno`, Users.email AS `Users__email` FROM users Users LIMIT 20 OFFSET 0
Thanks guys and #RiggsFolly nice to have observerd that in the SQL The error was from the space in the column contact person instead of contactperson in the SQL
MySQL 1064 error in CodeIgniter?
I have query INSERT INTO subscriptions ( client_id, name, group_id, type ) SELECT clients.id, 'Индивидуал', 0, 1 FROM clients WHERE clients.individual=1; ALTER TABLE clients DROP COLUMN clients.individual; ALTER TABLE finance_operations ADD COLUMN sub_id INT NOT NULL DEFAULT 0; which works fine in Mysql Workbench. But if I use it in codeIgniter code: $this->db->simple_query($query); I get error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE clients DROP COLUMN clients.individual; ALTER TABLE' at line 4
PDO can not run more than one question one time; This code is right: $array = [ "query1", "query2", "query3" ]; foreach($array as $query) $this->db->simple_query($query);
Why is this SQL incorrect (MySQL)?
I have a following query: "DELETE * FROM Participations WHERE scheduleId IN (SELECT id FROM Schedule WHERE meetingId = :meetingId) AND userId = :userId" I assign variables using PDO properly. In response I get: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM Participations WHERE scheduleId IN (SELECT id FROM Schedule WHERE meeting' at line 1} It is enough that I replace first DELETE with SELECT and query is done properly. Besides when I test directly in phpMyAdmin the same query with DELETE in it works fine. I am confused....
Use DELETE FROM (note the lack of *) instead.
The error message clearly indicates that it is a syntax error near '*'. Remove * from your Delete statement DELETE FROM Participations WHERE scheduleId IN (SELECT id FROM Schedule WHERE meetingId = :meetingId) AND userId = :userId
MySQL NOT EXITS condition not working
Hello I am trying to execute a mysql query but getting error which I can't understand. The query I am using is INSERT INTO summary (oid,tab,cost) VALUES('1','7','40') WHERE NOT EXISTS (SELECT * FROM summary WHERE cusid ='1') I am using this tutorial as my reference, http://www.techonthenet.com/mysql/exists.php This is the structure of the summary table This is the error message #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use new 'WHERE NOT EXISTS (SELECT * FROM summary WHERE cusid = 1)' at line 1
It is not exits. Change it to exists. INSERT INTO summary (oid,tab,cost) VALUES('1','7','40') WHERE NOT EXISTS (SELECT * FROM summary WHERE cusid ='1') ^ Also you can't use NOT EXISTS with your above query, you can with a subquery.