MortHub MortHub - 1 year ago 77
SQL Question

Inner Join Error joining two tables - small syntax error I'm assuming

I have a tickets table and a customers table. I'm trying to take basic information from the tickets table, and simply add the clientDisplayName field from the customers table that corresponds to the the clientID field in the ticket table.

I also need to verify whether the where clause is right, I only want it to return ticket info where the ticketstatus IS NOT EQUAL to "closed" Should I use <> or IS NOT EQUAL TO?

I'm getting a #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 '"SELECT, t.clientID, c.clientDisplayName, t.ticketTitle t.ticketDueDate t.t' at line 1

Here's my query, I just started using PDO, but I believe my issue is just with the join as I'm new to that also:

t.ticketLastModifiedDate FROM `tickets` AS t
INNER JOIN `customers` AS c ON t.clientID =
WHERE t.ticketStatus <> "closed"
ORDER BY t.ticketDueDate ASC");

Answer Source

Missing , after column names starting from t.ticketTitle.

You are using " as your string for the prepare so you need to put ' around closed so it doesn't think you a closing the original string. E.g. WHERE t.ticketStatus <> 'closed'

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