Skip to content

SQL Syntax incompatible with MySQL #75

@ApertureDevelopment

Description

@ApertureDevelopment

A bug was just discovered within the nested SQL statements. It appears that the current nested selects for the insert queries are all not working with a regular mysql database.

This syntax:

INSERT INTO `tbl_mrsync` (user_id, rank, server_group)
VALUES (
    (SELECT p_user_id FROM tbl_users WHERE steamid=? AND steamid64=?), 
?, 
    (SELECT p_group_id FROM tbl_server_grp WHERE group_name=?)
)
ON DUPLICATE KEY UPDATE rank=VALUES(rank);

is only MariaDB specific and does not work with MySQL 8. The proper syntax to use for the example given above would be

INSERT INTO `tbl_mrsync` (user_id, rank, server_group) 
SELECT tbl_users.p_user_id, ?, tbl_server_grp.p_group_id
FROM tbl_users, tbl_server_grp
WHERE
  tbl_users.steamid=? AND tbl_users.steamid64=?
AND
  tbl_server_grp.group_name=?
ON DUPLICATE KEY UPDATE rank=VALUES(rank);

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions