Raised This Month: $51 Target: $400
 12% 

sql query morerows


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pride95
Senior Member
Join Date: Aug 2015
Old 12-18-2016 , 08:10   sql query morerows
Reply With Quote #1

PHP Code:
FormatEx(querysizeof(query), "SELECT count(*), s2.score, s2.hours FROM table s JOIN table s2 ON s2.steamid = '%s' AND (s.score > s2.score OR s.score = s2.score AND s.name <= s2.name);"Steam); 
For this query SQL_MoreRows returns true even if my database is empty. i need to create another query for false:

PHP Code:
select x form table while steamid ""this is examplenot the code from plugin 
why for the first query morerows returns true and for the second returns false?

Last edited by pride95; 12-18-2016 at 09:55.
pride95 is offline
quake84
Junior Member
Join Date: Aug 2014
Location: Poland
Old 12-18-2016 , 10:49   Re: sql query morerows
Reply With Quote #2

Because the "count(*)" in your query will always return a row with the result of the count(*) function regardless of the data - that is, even if the table is empty!!!!
__________________
...

Last edited by quake84; 12-18-2016 at 10:56.
quake84 is offline
pride95
Senior Member
Join Date: Aug 2015
Old 12-18-2016 , 12:55   Re: sql query morerows
Reply With Quote #3

so, something like this will works?

HTML Code:
if(!SQL_MoreRows(hndl) || !SQL_FetchInt(hndl, 0))
SQL_FetchInt = count(*)

Last edited by pride95; 12-18-2016 at 13:16.
pride95 is offline
quake84
Junior Member
Join Date: Aug 2014
Location: Poland
Old 12-18-2016 , 14:09   Re: sql query morerows
Reply With Quote #4

if(!SQL_MoreRows(hndl) || (SQL_FetchRow(hndl) && !SQL_FetchInt(hndl, 0)))

You need to FetchRow() before fetching anything from a row.
__________________
...
quake84 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 02:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode