This is a discussion on Syntax frustration within the MySQL forums, part of the Database Server Software category; --> I'm getting a syntax complaint with the following query SELECT documents.DocPassportFirstName, documents.DocPassportFamilyName, countries.ConNationality, documents.DocPassportNo, documents.DocPassportIssueDate, documents.DocPassportPlaceOfIssue, documents.DocPassportExpiryDate, documents.DocDLFirstName, documents.DocDLFamalyName, ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm getting a syntax complaint with the following query SELECT documents.DocPassportFirstName, documents.DocPassportFamilyName, countries.ConNationality, documents.DocPassportNo, documents.DocPassportIssueDate, documents.DocPassportPlaceOfIssue, documents.DocPassportExpiryDate, documents.DocDLFirstName, documents.DocDLFamalyName, documents.DocDLNationality, documents.DocDLNo, documents.DocBdcWith, documents.DocBdcPolNo, documents.DocBdcTelNo, documents.DocBdcExpiryDate, documents.DocMOTDue, documents.DocCCP, documents.DocCCPPolNo, documents.DocCCPTelNo, documents.DocUpDate FROM documents, countries WHERE documents.DocPassportNationalty = countries.ConID AND MemberID = $memberid; MySQL Error: 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 '' at line 1 I can't see what is wrong with it! Can anyone else see my mistake? |
| |||
| On 31 Jan, 14:06, "Dan" <dp_pea...@hotmail.com> wrote: > I'm getting a syntax complaint with the following query > > SELECT documents.DocPassportFirstName, > documents.DocPassportFamilyName, > countries.ConNationality, > documents.DocPassportNo, > documents.DocPassportIssueDate, > documents.DocPassportPlaceOfIssue, > documents.DocPassportExpiryDate, > documents.DocDLFirstName, > documents.DocDLFamalyName, > documents.DocDLNationality, > documents.DocDLNo, > documents.DocBdcWith, > documents.DocBdcPolNo, > documents.DocBdcTelNo, > documents.DocBdcExpiryDate, > documents.DocMOTDue, > documents.DocCCP, > documents.DocCCPPolNo, > documents.DocCCPTelNo, > documents.DocUpDate > FROM documents, countries > WHERE documents.DocPassportNationalty = countries.ConID > AND MemberID = $memberid; > > MySQL Error: 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 '' at line 1 > > I can't see what is wrong with it! Can anyone else see my mistake? try echoing the query |
| |||
| On 31 Jan, 14:06, "Dan" <dp_pea...@hotmail.com> wrote: > I'm getting a syntax complaint with the following query > > SELECT documents.DocPassportFirstName, > documents.DocPassportFamilyName, > countries.ConNationality, > documents.DocPassportNo, > documents.DocPassportIssueDate, > documents.DocPassportPlaceOfIssue, > documents.DocPassportExpiryDate, > documents.DocDLFirstName, > documents.DocDLFamalyName, > documents.DocDLNationality, > documents.DocDLNo, > documents.DocBdcWith, > documents.DocBdcPolNo, > documents.DocBdcTelNo, > documents.DocBdcExpiryDate, > documents.DocMOTDue, > documents.DocCCP, > documents.DocCCPPolNo, > documents.DocCCPTelNo, > documents.DocUpDate > FROM documents, countries > WHERE documents.DocPassportNationalty = countries.ConID > AND MemberID = $memberid; > > MySQL Error: 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 '' at line 1 > > I can't see what is wrong with it! Can anyone else see my mistake? I tried pasting it into phpMyAdmin and all it said to me was that the tables didn't exist. No SQL error was posted. |
| |||
| On Jan 31, 3:30 pm, "Captain Paralytic" <paul_laut...@yahoo.com> wrote: > On 31 Jan, 14:06, "Dan" <dp_pea...@hotmail.com> wrote: > > > > > I'm getting a syntax complaint with the following query > > > SELECT documents.DocPassportFirstName, > > documents.DocPassportFamilyName, > > countries.ConNationality, > > documents.DocPassportNo, > > documents.DocPassportIssueDate, > > documents.DocPassportPlaceOfIssue, > > documents.DocPassportExpiryDate, > > documents.DocDLFirstName, > > documents.DocDLFamalyName, > > documents.DocDLNationality, > > documents.DocDLNo, > > documents.DocBdcWith, > > documents.DocBdcPolNo, > > documents.DocBdcTelNo, > > documents.DocBdcExpiryDate, > > documents.DocMOTDue, > > documents.DocCCP, > > documents.DocCCPPolNo, > > documents.DocCCPTelNo, > > documents.DocUpDate > > FROM documents, countries > > WHERE documents.DocPassportNationalty = countries.ConID > > AND MemberID = $memberid; > > > MySQL Error: 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 '' at line 1 > > > I can't see what is wrong with it! Can anyone else see my mistake? > > I tried pasting it into phpMyAdmin and all it said to me was that the > tables didn't exist. No SQL error was posted. I suspect the error is in the contents of $memberid - but without seeing the echoed query it's difficult to tell. |
| |||
| Dan wrote: > I'm getting a syntax complaint with the following query > > SELECT documents.DocPassportFirstName, > documents.DocPassportFamilyName, > countries.ConNationality, > documents.DocPassportNo, > documents.DocPassportIssueDate, > documents.DocPassportPlaceOfIssue, > documents.DocPassportExpiryDate, > documents.DocDLFirstName, > documents.DocDLFamalyName, > documents.DocDLNationality, > documents.DocDLNo, > documents.DocBdcWith, > documents.DocBdcPolNo, > documents.DocBdcTelNo, > documents.DocBdcExpiryDate, > documents.DocMOTDue, > documents.DocCCP, > documents.DocCCPPolNo, > documents.DocCCPTelNo, > documents.DocUpDate > FROM documents, countries > WHERE documents.DocPassportNationalty = countries.ConID > AND MemberID = $memberid; > > MySQL Error: 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 '' at line 1 > > I can't see what is wrong with it! Can anyone else see my mistake? > Two suggestions. First, try putting $memberid in quotes. Second, verify the spelling of each of your column names. HTH Jerry |
| |||
| Jerry Gitomer wrote: >> WHERE documents.DocPassportNationalty = countries.ConID >> AND MemberID = $memberid; >> >> MySQL Error: 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 '' at line 1 >> >> I can't see what is wrong with it! Can anyone else see my mistake? >> > Two suggestions. First, try putting $memberid in quotes. Second, verify > the spelling of each of your column names. No - don't do that. Numbers should not be enclosed in quotes. |
| |||
| On Jan 31, 11:50 pm, Sanders Kaufman <b...@kaufman.net> wrote: > Jerry Gitomer wrote: > >> WHERE documents.DocPassportNationalty = countries.ConID > >> AND MemberID = $memberid; > > >> MySQL Error: 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 '' at line 1 > > >> I can't see what is wrong with it! Can anyone else see my mistake? > > > Two suggestions. First, try putting $memberid in quotes. Second, verify > > the spelling of each of your column names. > > No - don't do that. > Numbers should not be enclosed in quotes. you don't know that it's a number |
| |||
| strawberry wrote: > On Jan 31, 11:50 pm, Sanders Kaufman <b...@kaufman.net> wrote: >> Jerry Gitomer wrote: >>>> WHERE documents.DocPassportNationalty = countries.ConID >>>> AND MemberID = $memberid; >>>> MySQL Error: 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 '' at line 1 >> No - don't do that. >> Numbers should not be enclosed in quotes. > > you don't know that it's a number I don't know that the sun will rise tomorrow, either, but I'll bet you a PayPal dollar on it. For one thing - the error that came back wasn't bitching about that particular problem. There's a different error that comes back for cast problems like that. This one is a *syntax* error. That means that somewhere there's a misspled word, an out-of-place comma, or an unclosed quote, comma or parenthesis. For another thing - ID's are like *always* numbers. Using the AUTO_NUMBER feature to create PK's named "id" is just too THE way to do it. If somebody does PK's in MySQL any other way - I'd always suggest they do it this way, instead. Indeed using that kind of PK instead of some string is probably the easiest way to speed up queries and such - because numbers are sooo NOT resource intensive to index. |
| ||||
| Dan wrote: > I'm getting a syntax complaint with the following query > > SELECT documents.DocPassportFirstName, > documents.DocPassportFamilyName, > countries.ConNationality, > documents.DocPassportNo, > documents.DocPassportIssueDate, > documents.DocPassportPlaceOfIssue, > documents.DocPassportExpiryDate, > documents.DocDLFirstName, > documents.DocDLFamalyName, > documents.DocDLNationality, > documents.DocDLNo, > documents.DocBdcWith, > documents.DocBdcPolNo, > documents.DocBdcTelNo, > documents.DocBdcExpiryDate, > documents.DocMOTDue, > documents.DocCCP, > documents.DocCCPPolNo, > documents.DocCCPTelNo, > documents.DocUpDate > FROM documents, countries > WHERE documents.DocPassportNationalty = countries.ConID > AND MemberID = $memberid; > > MySQL Error: 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 '' at line 1 > > I can't see what is wrong with it! Can anyone else see my mistake? > Is MemberID a field in documents or in countries table? I say near to near '' that's sign that $memberid is NULL and then you should use NULL in Field description and you didn't or some other thing show us more code and the table definition |