Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
mySQL Query : Can't do this?
Old 04-25-2006, 04:44 PM Re: mySQL Query : Can't do this?
Skilled Talker

Posts: 69
Trades: 0
Exact copy of the query, and how do I find out my mySQL version?
Reality15 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-25-2006, 05:01 PM Re: mySQL Query : Can't do this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
select version()
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-25-2006, 05:03 PM Re: mySQL Query : Can't do this?
Skilled Talker

Posts: 69
Trades: 0
Result is : 4.1.18-standard-log
Reality15 is offline
Reply With Quote
View Public Profile
 
Old 04-25-2006, 06:16 PM Re: mySQL Query : Can't do this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
can you run off a data dump of the database so I can rebuild the structure and test

email it to me I'll see if I can recreate the error.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-25-2006, 07:31 PM Re: mySQL Query : Can't do this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the table alias with the count function is the problem

simply a.*, count(*) AS music works ok

odd it worked ok with my earlier testing, but heyho.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-25-2006, 07:37 PM Re: mySQL Query : Can't do this?
Skilled Talker

Posts: 69
Trades: 0
So it would be...

SELECT b.realname,a.*, count(*) AS `music` FROM `sounds` AS a LEFT JOIN `staff` AS b ON b.id = a.staffid GROUP BY `category` WHERE `category` = CONVERT(_utf8 'Front Gate' USING latin1) COLLATE latin1_general_ci ORDER BY `id` ASC

And that didn't work either.

#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 'WHERE `category` = CONVERT( _utf8 'Front Gate' USING latin1 ) COLLATE latin1_gen' at line 1
Reality15 is offline
Reply With Quote
View Public Profile
 
Old 04-25-2006, 07:47 PM Re: mySQL Query : Can't do this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
take the single quotes from around the column names, these are only required when you are trying to use reserved words as field names.

I can't test with the JOINs the dump only had the one table.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-25-2006, 07:49 PM Re: mySQL Query : Can't do this?
Skilled Talker

Posts: 69
Trades: 0
SQL Query :

SELECT b.realname,a.*, count(*) AS music FROM sounds AS a LEFT JOIN staff AS b ON b.id = a.staffid GROUP BY category WHERE category = CONVERT(_utf8 'Front Gate' USING latin1) COLLATE latin1_general_ci ORDER BY `id` ASC

Result :

#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 'WHERE category = CONVERT( _utf8 'Front Gate' USING latin1 ) COLLATE latin1_gener' at line 1

lol, this is probably really annoying you as much as it is me.
Reality15 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2006, 03:23 AM Re: mySQL Query : Can't do this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
a WHERE clause has to be before a GROUP BY
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-26-2006, 06:20 AM Re: mySQL Query : Can't do this?
Skilled Talker

Posts: 69
Trades: 0
Alright, I got that one to work, but this one, on the actual page to display the songs...

$result = mysql_query("SELECT * FROM `sounds` WHERE `category` = $category ORDER BY `songname` ASC");

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 'ORDER BY `songtitle` ASC' at line 1

Any idea why?

Last edited by Reality15; 04-26-2006 at 06:37 AM..
Reality15 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2006, 07:35 AM Re: mySQL Query : Can't do this?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
wrap $category in single quotes as it is a string
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-26-2006, 07:39 AM Re: mySQL Query : Can't do this?
Novice Talker

Posts: 10
Location: Doncaster, UK
Trades: 0
Quote:
Originally Posted by Reality15
Alright, I got that one to work, but this one, on the actual page to display the songs...

$result = mysql_query("SELECT * FROM `sounds` WHERE `category` = $category ORDER BY `songname` ASC");

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 'ORDER BY `songtitle` ASC' at line 1

Any idea why?
Try this...


$result = mysql_query("SELECT * FROM `sounds` WHERE `category` = '$category' ORDER BY `songname` ASC");

It should correct the error (hopefully).

Edit: - Started typing this before Chris' response.

Last edited by robterrace; 04-26-2006 at 07:42 AM..
robterrace is offline
Reply With Quote
View Public Profile Visit robterrace's homepage!
 
Old 04-26-2006, 03:03 PM Re: mySQL Query : Can't do this?
Skilled Talker

Posts: 69
Trades: 0
Works great now! Thanks for the continuous support guys!
Reality15 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to mySQL Query : Can't do this?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.71476 seconds with 11 queries