scott532 Posted May 14, 2006 Share Posted May 14, 2006 Hey people,I am trying to figure out what this means:[code]$sql = sprintf("SELECT COUNT(*) AS test FROM %s WHERE email = '%s' OR login = '%s'", $this->table_name, $this->user_email, $this->user);[/code]I have searched through my PHP book (by Eric Rosebrock) and searched the MySQL docs, but I cannot figure out, specifically, what the following are:[ol type=\'1\'][*]What is [code]AS Test[/code] referring to?[*]What is the purpose of [code]%s[/code]?[/ol]If someone could explain these two questions I will be greatful.Thanks- for putting up with a [i]newb[/i],Scott G. Link to comment https://forums.phpfreaks.com/topic/9630-trouble-understanding-mysql-syntax/ Share on other sites More sharing options...
Carth Posted May 14, 2006 Share Posted May 14, 2006 [a href=\"http://www.php.net/sprintf\" target=\"_blank\"]sprintf()[/a] replaces %s with the variables supplied in the second parameter, in the order they are provided. So "FROM %s" will turn into "FROM $this->table_name".The "COUNT(*) AS test" is a way of getting the number of rows returned, and it will be returned in a column called "Test", there should be something in the manual under SELECT about it Link to comment https://forums.phpfreaks.com/topic/9630-trouble-understanding-mysql-syntax/#findComment-35585 Share on other sites More sharing options...
scott532 Posted May 14, 2006 Author Share Posted May 14, 2006 Thanks Carth, i get it now. Link to comment https://forums.phpfreaks.com/topic/9630-trouble-understanding-mysql-syntax/#findComment-35587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.