Actually, when you use the as construct it becomes alias.column_name rather than table_name.column_name
In a syntactic sense, the column_name should be referenced by the alias , however in a technical sense, this is not true, proved by the fact that the code has worked up until now. Later releases of MySQL are now adhering 'more to' to SQL standards/compliance, in relation to syntax, like the parentheses in table_references in versions prior to 5.01
HTH
MOD is a MySQL function name (modulus), so it can't be used on it's own to reference a column. So either tablename.mod OR `mod` (backticks) could be used. That would not have worked in any version of MySQL.
In this case, MySQL sees "mod" and then looks for an opening (, but doesn't find it - it finds an "=", so that's the error you see.
Joins can be done also using "USING" if both tables being joined have a column name in common.
Paul,
You are a genius, thanks. I couldn't understand why, in php, the query returned a FALSE all the time, when in phpMyAdmin, I run the same query and all is okay. Of course phpMyAdmin adds the 'ticks', but it always does that for any column. In the end I added a 'quick fix' ....
after the 'mysql_query()' function, because the function is just to check for users who are blocked, and no-one had that value anyway. This db is just a temp measure.
Thanks for the tip on MOD. /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />
J
edit: - just added the ticks to make it 'mod' and there are no errors now.
There is a system that has been used in the past, so we know the code 'works'. Now it is being used as a temporary measure and is crashing on the mysql syntax, here is some of the code that get syntax errors.
and the msg from mySQL is
Wasn't there something about left joins are now more 'strict' in syntax, but I think that was with mySQL version ?? and upwards.
The versions are:
Apache version 1.3.34 (Unix)
PERL version 5.8.7
PHP version 4.4.1
MySQL version 4.1.18-standard
Here is the structure of the USERS table
-- Table structure for table `users`
--
CREATE TABLE `users` (
`ID` int(11) NOT NULL auto_increment,
`nick` varchar(20) NOT NULL default '',
`pass` varchar(20) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`datae` date NOT NULL default '0000-00-00',
`gen` tinytext NOT NULL,
`zi` tinyint(2) unsigned NOT NULL default '0',
`luna` tinyint(2) unsigned NOT NULL default '0',
`ann` year(4) NOT NULL default '0000',
`titlu` varchar(60) NOT NULL default '',
`descriere` text NOT NULL,
`oras` varchar(60) NOT NULL default '',
`poza` tinyint(1) unsigned default NULL,
`blocat` tinyint(1) unsigned NOT NULL default '0',
`contor` int(11) NOT NULL default '0',
`mod` tinyint(1) unsigned NOT NULL default '0',
`inreg` date NOT NULL default '0000-00-00',
`last` date NOT NULL default '0000-00-00',
`credits` smallint(5) unsigned NOT NULL default '0',
`sendmessage` int(1) unsigned NOT NULL default '0',
`search` text NOT NULL,
`zip` varchar(10) NOT NULL default '',
`zodie` smallint(5) unsigned NOT NULL default '0',
`loc` smallint(5) unsigned NOT NULL default '0',
`state` smallint(5) unsigned NOT NULL default '0',
`caut` varchar(20) default NULL,
`nad` int(1) unsigned NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`email_notification` tinyint(1) unsigned NOT NULL default '1',
`email_format_html` tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`),
KEY `nick` (`nick`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=406 ;
Woops, the cols ...
blocat
mod
nad
gen
last
are all from USERS, so shouldn't that be ?
anyway, will give that a try. Don't know why it worked before ??
J
"The church is never a place, but always a people;
never a fold but always a flock;
never a building but always a believing assembly.
The church is you who pray,
not where you pray."
-Anonymous