Jump to content

Table Structure Question


Padgoi

Recommended Posts

$q = 'SELECT y.*, (SUM(`rating`)/COUNT(`rating`)) AS `avg`, COUNT(`rating`) AS `num_rat` FROM `groupcomic` `y` LEFT JOIN `yrat` ON `sid` = `skey` where panels>=3  GROUP BY `sid` ORDER BY `avg` DESC LIMIT 0,5';

This line seems to be causing problems in one of my scripts in that it keeps referring me to this line and saying there is an invalid MYSQL result resource.  I'm fairly certain my table structure is off.  Can someone please tell me, based on this line, what fields I should have in my table and and what type they should be?  

 

I know the table name is groupcomic.  

Link to comment
https://forums.phpfreaks.com/topic/277309-table-structure-question/
Share on other sites

Yeah, it's actually 2 tables, groupcomic and yrat.  I ran the query directly in MYSQL and got this error:

#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 '$q = 'SELECT y.*, (SUM(`rating`)/COUNT(`rating`)) AS `avg`, COUNT(`rating`) AS `' at line 1

I assume it has something to do with the num_rat field but I honestly have no idea.  I had that field set up as INT (11).

about the only way you could get that error from that sql statement is if you left the leading or trailing php single quote ' on it when you copied/pasted it into mysql to run it. the sql you posted doesn't produce that error for me when i tried it directly in mysql.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.