Vitaliy  Matveev Vitaliy Matveev - 1 year ago 41
MySQL Question

Correct syntax for joins

I've got a problem with phpmyadmin syntax. Here is my query:

SELECT
CONCAT_WS(',', visitor_name, visitor_email, visitor_phone) AS visitor_info,
session_geoip_country,
session_geoip_city,
visitor_chats_count,
agents_names,
chat_id,
SUBSTRING( visitor_description, 1, 100 ) AS Manager_note
FROM
client_jivo_chat_finished
INNER JOIN
client_jivo_chat_finished_messages.timestamp, client_jivo_chat_finished_messages.message
ON
client_jivo_chat_finished_messages.chat_id = client_jivo_chat_finished.chat_id


and error is:


"#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 'ON client_jivo_chat_finished_messages.chat_id = client_jivo_chat_finished.chat_i' at line 8"

Answer Source

Your syntax is not correct as you are joining table column. Here is the modified version. Hope this works.

SELECT
    CONCAT_WS(',', visitor_name, visitor_email, visitor_phone) AS visitor_info,
    session_geoip_country,  
    session_geoip_city,
    visitor_chats_count,
    agents_names, 
    chat_id,
    SUBSTRING( visitor_description, 1, 100 ) AS Manager_note
FROM
    client_jivo_chat_finished
INNER JOIN
    client_jivo_chat_finished_messages 
ON
    client_jivo_chat_finished_messages.chat_id = client_jivo_chat_finished.chat_id

You shoud join two table on a column. Just remove this part.

INNER JOIN client_jivo_chat_finished_messages.timestamp, client_jivo_chat_finished_messages.message

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download