Whats wrong with this SQL?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Whats wrong with this SQL?

Post by JayBird »

Okay,

This SQL query causes the server to crash...tried it on 3 different servers, all with the same effect.

Code: Select all

SELECT `q`.`id` as `mainID`, `q`.`qgid`, `q`.`section`, `q`.`fieldType`, `a`.`qid`, `a`.`uid`, `a`.`answer` as `mainAnswer`, `sa`.`id`, `sa`.`answer`

FROM `gradlife_co_uk_-_gradlife`.`questions` as `q`, `gradlife_co_uk_-_gradlife`.`answers` as `a`, `gradlife_co_uk_-_gradlife`.`setanswers` as `sa`

INNER JOIN `gradlife_co_uk_-_gradlife`.`answers` ON `q`.`id` = `a`.`qid`

GROUP BY `q`.`id`, `a`.`uid` ORDER BY `a`.`uid`

Any ideas?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I've never seen this sort of syntax before:

`alias`.`name`

Get rid of all back ticks and try just:

alias.name

That's what I'd change.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

backticks are perfectly acceptable in queries...infact my host requires that queries are structured like this
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Whats wrong with this SQL?

Post by Weirdan »

Pimptastic wrote:Okay,

This SQL query causes the server to crash...tried it on 3 different servers, all with the same effect.
what do mysql server's error logs say then?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Nothing at all useful

Code: Select all

051124 16:31:47	      1 Query       SELECT `q`.`id` as `mainID`, `q`.`qgid`, `q`.`section`, `q`.`fieldType`, `a`.`qid`, `a`.`uid`, `a`.`answer` as `mainAnswer`, `sa`.`id`, `sa`.`answer`

FROM `gradlife_co_uk_-_gradlife`.`questions` as `q`, `gradlife_co_uk_-_gradlife`.`answers` as `a`, `gradlife_co_uk_-_gradlife`.`setanswers` as `sa`

INNER JOIN `gradlife_co_uk_-_gradlife`.`answers` ON `q`.`id` = `a`.`qid`

GROUP BY `q`.`id`, `a`.`uid` ORDER BY `a`.`uid`
C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqld-nt, Version: 4.1.10-nt-log. started with:
TCP Port: 3306, Named Pipe: MySQL
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Re: Whats wrong with this SQL?

Post by n00b Saibot »

Pimptastic wrote:Any ideas?
No ideas... my brain crashed while reading it 8O
Post Reply