MySQL : error in your SQL syntax | LIMIT 0, 25 - mysql

I dont understand this error, guys please help me. why I am getting this error..
Is there something wrong in my query?
this is the 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 'LIMIT 0, 25' at line 7
and this is my query:
SELECT
equivalent
FROM
tb_student_record
INNER JOIN
tb_student ON tb_student_record.stud_id = tb_student.stud_id
WHERE
tb_student_record.instructor_id = 'INST-20131296'
AND tb_student_record.criteria_id = '1'
AND tb_student_record.class_record_id = '1'
AND (CONCAT(stud_fname, ' ', stud_lname) = 'Jeffrey Oliveras'
AND tb_student_record.term = 'Prelim'

you are missing closing paranthesis at concat function
SELECT equivalent FROM tb_student_record INNER JOIN tb_student ON tb_student_record.stud_id=tb_student.stud_id
WHERE tb_student_record.instructor_id = 'INST-20131296'
AND tb_student_record.criteria_id = '1'
AND tb_student_record.class_record_id = '1'
AND (CONCAT(stud_fname, ' ', stud_lname) = 'Jeffrey Oliveras' )
AND tb_student_record.term = 'Prelim'

It seems that your query have problem at the end:

Related

MySQL Query using POST data always return wrong syntax

if (isset($_POST['id'])) {
$row = $db->row("
SELECT calendar_id, calendar_title, calendar_datetimestart, calendar_datetimeend, calendar_dow, calendar_color
FROM (
SELECT academic_schedule_id AS calendar_id, academic_schedule_name AS calendar_title, academic_schedule_datetimestart AS calendar_datetimestart, academic_schedule_datetimeend AS calendar_datetimeend, academic_schedule_dow AS calendar_dow, '#6453e9' AS calendar_color
FROM academic_schedule_table
WHERE academic_schedule_faculty = '".$_SESSION['siswa_faculty']."' AND academic_schedule_status = 'Active'
UNION ALL
SELECT appointment_table.dosen_schedule_id AS calendar_id, dosen_schedule_table.dosen_schedule_name AS calendar_title, dosen_schedule_table.dosen_schedule_datetimestart AS calendar_datetimestart, dosen_schedule_table.dosen_schedule_datetimeend AS calendar_datetimeend, Null AS calendar_dow, '#28464b' AS calendar_color
FROM appointment_table
INNER JOIN dosen_table ON dosen_table.dosen_id = appointment_table.dosen_id
INNER JOIN dosen_schedule_table ON dosen_schedule_table.dosen_schedule_id = appointment_table.dosen_schedule_id
WHERE appointment_table.siswa_id = ".$_SESSION['siswa_id']." AND appointment_table.status = 'Disetujui'
) WHERE calendar_id = ".$_POST['id']."");
I'm trying to POST 'id' and the data is showing up but it always give me syntax error
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE calendar_id = 13
Where i did it wrong?

Why is MySQL rejecting the following query?

UPDATE table_one
SET user_accessible = 1
WHERE volume == 2
AND lesson_order == '04'
LIMIT 1
It's giving the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= '2' AND lesson_order == '04') LIMIT 1' at line 1
The query looks correct to me :(
You made a mistake on your comparison. Use single = not ==
UPDATE table_one
SET user_accessible = 1
WHERE volume = 2
AND lesson_order = '04'
LIMIT 1

Empty record MySQL, how find?

Please help to fix this error:
SELECT SQL_CACHE p.user_id, p.project_id, p.cid, p.project_title, p.additional_info, p.buynow_price, p.date_added, p.highlite, p.project_details, p.views, p.bids, p.currentprice, p.currencyid, p.buynow, p.filtered_auctiontype, p.buynow_purchases, p.date_starts, p.buynow_qty_lot, p.items_in_lot, UNIX_TIMESTAMP(p.date_end) - UNIX_TIMESTAMP('2017-08-05 18:14:50') AS mytime, UNIX_TIMESTAMP(p.date_starts) - UNIX_TIMESTAMP('2017-08-05 18:14:50') AS starttime, p.donation, p.filter_budget, p.reserve, p.project_state, p.bid_details, p.filter_escrow, p.filter_gateway, p.charityid, p.jobs_price
          FROM xxx_projects AS p
          LEFT JOIN xxx_users u ON(p.user_id = u.user_id)
          WHERE p.visible = '1'
          AND p.status = 'open'
          AND p.project_state = 'product'
          AND u.status = 'active'
          AND p.project_id IN (88414723, 5043541, 98506492, 36121136, 84626697, , 4408122, 49183201, 56318356, 89533629, 16433073, 70069844, 6242686, 8745727, 10816822, 8745727, 27902749, 41807041, 61556755, 46837725, 38855144, 69491982, 27240408, 20425411)
          
MySQL Error  : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right
syntax to use near ' 4408122, 49183201, 56318356, 89533629, 16433073,
70069844, 6242686, 8745727, 10' at line 8
I think in db is empty record but i can'f find it...
You have a double comma in 84626697, , 4408122. Just remove one comma (i.e., make it 84626697, 4408122) and you should be good to go.

MySQL SELECT syntax error that I am not able to identify

I am trying a simple query in mysql and I am getting a syntax error that I need help understanding.
SELECT
eea.*,
ee.description,
eect.title,
eect.file,
eect.location,
eect.img_location
FROM
`e_exam` ee,
`e_exam_attempt` eea,
`e_exam_cert_template` eect
WHERE
eea.a_user_id = 1,
eea.ee_id = ee.id,
ee.eect_id = eect.id;
I am getting the following error:
Basically the syntax error on line 13
eea.ee_id = ee.id, ee.eect_id = eect.id LIMIT 0, 25
Anyone have idea how I can edit this to get the -1 vote to improve?
Its a simple syntax error, your WHERE clause should not be seperated by commas. Use AND or OR etc
SELECT
eea.*, ee.description, eect.title, eect.file,
eect.location,eect.img_location
FROM
`e_exam` ee,
`e_exam_attempt` eea,
`e_exam_cert_template` eect
WHERE
eea.a_user_id = 1 AND
eea.ee_id = ee.id AND
ee.eect_id = eect.id
LIMIT 0,25
You should also learn about the JOIN syntax
SELECT
eea.*, ee.description, eect.title,eect.file,
eect.location, eect.img_location
FROM `e_exam_attempt` eea
JOIN `e_exam` ee ON eea.ee_id = ee.id
JOIN `e_exam_cert_template` eect ON ee.eect_id = eect.id
WHERE
eea.a_user_id = 1
LIMIT 0,25

SQL error #1064 when nesting a SELECT MAX in a LEFT JOIN

Please let me know why I get an error on the following SQL (I am using a MySQL database) and how to rectify it:
SELECT at_award_description.ad_id,
at_award_description.ad_detail,
at_award_description.ad_archived_date,
a.cad_id,
a.cad_task_completion_date
FROM at_award_description
LEFT JOIN at_cub_award_date AS a ON ((at_award_description.ad_id = a.ad_id)
AND (a.ca_id = 37)
AND a.cad_task_completion_date = (SELECT MAX(b.cad_task_completion_date)
FROM at_cub_award_date AS b
WHERE a.ca_id = b.ca_id AND a.ad_id = b.ad_id
)
)
WHERE at_award_description.aw_id = 5
ORDER BY at_award_description.ad_order;
I broke the SQL down to ensure each part worked.
SELECT MAX(b.cad_task_completion_date)
FROM at_cub_award_date AS b
And
SELECT at_award_description.ad_id,
at_award_description.ad_detail,
at_award_description.ad_archived_date,
a.cad_id,
a.cad_task_completion_date
FROM at_award_description
LEFT JOIN at_cub_award_date AS a ON ((at_award_description.ad_id = a.ad_id)
AND (a.ca_id = 37)
)
WHERE at_award_description.aw_id = 5
ORDER BY at_award_description.ad_order;
Each of these work on their own. When I combine them I get the following error:
Error
SQL query:
LIMIT 0, 25
MySQL said:
#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 'LIMIT 0, 25' at line 1
Regards,
Glyn
EDIT
#Barmar came up with the solution to remove the ";" at the end when testing. However, the result was not what I expected so I ended up changing this to:
SELECT at_award_description.ad_id,
at_award_description.aw_id,
at_award_description.ad_group,
at_award_description.ad_detail,
at_award_description.ad_start_date,
at_award_description.ad_archived_date,
MAX(at_cub_award_date.cad_task_completion_date)
FROM at_award_description
LEFT JOIN at_cub_award_date ON ((at_award_description.ad_id = at_cub_award_date.ad_id)
AND (at_cub_award_date.ca_id = 37))
WHERE at_award_description.aw_id = 5
GROUP BY at_award_description.ad_group
ORDER BY at_award_description.ad_order, at_award_description.ad_group