select
pengarang_id,buku_judul,penerbit_id
from buku
left join bukupengarang on buku.penerbit_id = bukupengarang.pengarang_id
INTERSECT
select
pengarang_id,buku_judul,penerbit_id
from buku right join bukupengarang on buku.penerbit_id = bukupengarang.pengarang_id;`
ERROR 1064 (42000): 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 'INTERSECT
select pengarang_id,buku_judul,penerbit_id
from buku
right join bukup' at line 5
could anyone tell me whts problem here?
i dont understand abt this one, i just read it on inet n still didnt get it
MySQL does not support the INTERSECT operator. You can emulate the INTERSECT operator in MySQL using join clauses.
https://www.mysqltutorial.org/mysql-intersect/
It works with MariaDB since version 10.3.0.
Related
The query that is throwing an error for my MySQL DB is:
SELECT t1.GROUPNAME FROM user_group t0, group t1 WHERE ((t0.users_USERNAME =
?) AND (t1.GROUPNAME = t0.groups_GROUPNAME))
The error info is the following:
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 'group t1 WHERE
((t0.users_USERNAME = 'test') AND (t1.GROUPNAME = t0.groups_GROUP')
Okay so I know the problem is with the group t1 part. But I dont know what is wrong with it.
Click here to see that I have all the needed colums
Can any one find out what the problem could be here?
group is a reserved word in SQL. You should put quotes around it.
Some JPA providers do that automatically, whereas others don't ...
I just wanted to switch from sqlite3 to using MySQL but I get errors in this query:
SELECT
metapp_notif.id,
name,
age,
place,
note,
metapp_notif.lat,
metapp_notif.longt,
haslatlong,
dati,
ntype,
grpm_id,
image,
send_id,
pro.latitude,
pro.longtitude,
metapp_notif.dati,
metapp_notif.activity
FROM (metapp_notif
join (metapp_profil
join metapp_userlocation
ON metapp_profil.user_id = metapp_userlocation.user_id) AS pro
ON metapp_notif.send_id = pro.user_id)
WHERE metapp_notif.rec_id =% d;
I'm getting this error:
ERROR 1064 (42000): 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 'pro on metapp_notif.send_id=pro.user_id) where
metapp_notif.rec_id=2' at line 1
I was searching for differences between sqlite3 and mysql but can't figure out what is wrong.
Thanks in advance!
Try this syntax in Mysql
SELECT metapp_notif.id,
name,
age,
place,
note,
metapp_notif.lat,
metapp_notif.longt,
haslatlong,
dati,
ntype,
grpm_id,
image,
send_id,
latitude,
longtitude,
metapp_notif.dati,
metapp_notif.activity
FROM metapp_profil
join metapp_notif
ON metapp_notif.send_id = metapp_profil.user_id
join metapp_userlocation
ON metapp_profil.user_id = metapp_userlocation.user_id
WHERE metapp_notif.rec_id like '% d'; -- Not sure what you are trying to do here
MySQL query
select s.site_id,s.site_name,u.username
FROM cloud_search.dbo.site_request s join user_db.dbo.user_info u
on u.user_id=s.site_id;
Error
ERROR 1064 (42000): 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 '.site_request s join user_db.dbo.user_info u on u.user_id=s.site_id' at line 1
What am i doing wrong here..?
Are you sure you're using dbo it's usually for MSSQL
It's probably
select s.site_id,s.site_name,u.username FROM cloud_search.site_request s join user_db.user_info u on u.user_id=s.site_id;
SELECT core_student.STUDENT_ID, core_student.FIRST_NAME, core_student.LAST_NAME
FROM `core_student`
INNER_JOIN `ssp_student`
WHERE ssp_student.STUDENT_ID = core_student.STUDENT_ID;
throws an error on the WHERE clause:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to user near 'ssp_student' WHERE ssp_student.STUDENT_ID = core_student.STUDENT_ID
I just want to select the fields listed in the SELECT, then join all columns from ssp_student where the ssp_student.STUDENT_ID field is the same as the core_student.STUDENT_ID field.
Correct way is
SELECT core_student.STUDENT_ID, core_student.FIRST_NAME, core_student.LAST_NAME
FROM `core_student`
INNER JOIN `ssp_student`
on ssp_student.STUDENT_ID = core_student.STUDENT_ID;
I have the following query and it comes up with an error
SELECT CRM_PRESUPUESTOS.Fecha_Alta, CRM_PRESUPUESTOS.ID_VendedorAsignado, Sum([Precio]*(100-[CRM_PresupuestosDetalles].[Bonif])/100*[CRM_PresupuestosDetalles].[Cantidad]) AS LineaNeto
FROM CRM_PRESUPUESTOS RIGHT JOIN CRM_PresupuestosDetalles ON CRM_PRESUPUESTOS.ID_Presupuesto = CRM_PresupuestosDetalles.ID_Presupuesto
GROUP BY CRM_PRESUPUESTOS.Fecha_Alta, CRM_PRESUPUESTOS.ID_VendedorAsignado
HAVING ((DATE((CRM_PRESUPUESTOS.Fecha_Alta))=CurDate()));
The error is
[Err] 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 '[Precio](100-[CRM_PresupuestosDetalles].[Bonif])/100[CRM_PresupuestosDetalles‌​]' at line 1
How can I fix this? The problem probably is that I'm building them with Access
Square brackets, [ ], are t-sql specific. They tell the parser that the contained text is a string and keeps you safe from potentially mistakenly using a t-sql reserved word. The MySql similar way of doing this is with backticks: `
SELECT CRM_PRESUPUESTOS.Fecha_Alta,
CRM_PRESUPUESTOS.ID_VendedorAsignado,
Sum(`Precio`*(100-`CRM_PresupuestosDetalles`.`Bonif`)/100*`CRM_PresupuestosDetalles`.`Cantidad`) AS LineaNeto
FROM CRM_PRESUPUESTOS RIGHT JOIN CRM_PresupuestosDetalles ON CRM_PRESUPUESTOS.ID_Presupuesto = CRM_PresupuestosDetalles.ID_Presupuesto
GROUP BY CRM_PRESUPUESTOS.Fecha_Alta, CRM_PRESUPUESTOS.ID_VendedorAsignado
HAVING ((DATE((CRM_PRESUPUESTOS.Fecha_Alta))=CurDate()));
TRy this::
SELECT
CRM_PRESUPUESTOS.Fecha_Alta,
CRM_PRESUPUESTOS.ID_VendedorAsignado,
Sum(Precio*(100-CRM_PresupuestosDetalles.Bonif/100*CRM_PresupuestosDetalles.Cantidad) AS LineaNeto
FROM CRM_PRESUPUESTOS RIGHT
JOIN CRM_PresupuestosDetalles ON CRM_PRESUPUESTOS.ID_Presupuesto = CRM_PresupuestosDetalles.ID_Presupuesto
GROUP BY CRM_PRESUPUESTOS.Fecha_Alta, CRM_PRESUPUESTOS.ID_VendedorAsignado
HAVING DATEDIFF(CRM_PRESUPUESTOS.Fecha_Alta, CurDate)=0