Hi,
I'm trying to do a "join" kinda thing (relation) with a query. The table structures are:
CREATE TABLE IF NOT EXISTS `glinks_Advert_Relations` (
`ID` int(11) NOT NULL,
`CatName` char(255) NOT NULL,
KEY `CatName` (`CatName`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `glinks_Adverts` (
`ID` int(11) NOT NULL auto_increment,
`Image` char(255) NOT NULL default '',
`AdType` char(255) NOT NULL,
`WhereToShow` char(255) NOT NULL,
`Username` char(255) NOT NULL,
`HitCredit` float default NULL,
`HitPrice` float default NULL,
`ImpressionsLeft` int(11) default NULL,
`ImpressionUsed` int(11) default NULL,
`ExpirationMonth` char(20) default NULL,
`isActive` char(5) NOT NULL,
`AreasToShow` char(255) NOT NULL,
`DestinationURL` char(255) default NULL,
`FullCatList` longtext,
`NEWS` int(11) default NULL,
`ARTICLES` int(11) default NULL,
`VIDEO` int(11) default NULL,
`PINUP` int(11) default NULL,
`CONTESTS` int(11) default NULL,
`ALL_LISTINGS` int(11) default NULL,
`isDefault` int(11) NOT NULL default '0',
`ALLAREAS` int(11) default '0',
PRIMARY KEY (`ID`),
KEY `isactive` (`isActive`),
KEY `id` (`ID`),
KEY `adtype` (`AdType`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Now, what I'm trying to do is -:
SELECT * FROM glinks_Adverts,glinks_Advert_Relations WHERE ALLAREAS = 1 OR Advert_Relations.CatName = "British Columbia/Vancouver/Concrete/Cement Finishing"
How exacly would I go by this?
Basically - a bit of history as to why I'm trying to do this.
The "Advert" table just holds the advert (but can also have stuff like NEWS, ALLAREAS,etc. Then the "relation" table holds a list of the "categoires" this listing can show in.
I need to randomly select a value, but just can't get it working :/
TIA!
Andy
I'm trying to do a "join" kinda thing (relation) with a query. The table structures are:
CREATE TABLE IF NOT EXISTS `glinks_Advert_Relations` (
`ID` int(11) NOT NULL,
`CatName` char(255) NOT NULL,
KEY `CatName` (`CatName`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `glinks_Adverts` (
`ID` int(11) NOT NULL auto_increment,
`Image` char(255) NOT NULL default '',
`AdType` char(255) NOT NULL,
`WhereToShow` char(255) NOT NULL,
`Username` char(255) NOT NULL,
`HitCredit` float default NULL,
`HitPrice` float default NULL,
`ImpressionsLeft` int(11) default NULL,
`ImpressionUsed` int(11) default NULL,
`ExpirationMonth` char(20) default NULL,
`isActive` char(5) NOT NULL,
`AreasToShow` char(255) NOT NULL,
`DestinationURL` char(255) default NULL,
`FullCatList` longtext,
`NEWS` int(11) default NULL,
`ARTICLES` int(11) default NULL,
`VIDEO` int(11) default NULL,
`PINUP` int(11) default NULL,
`CONTESTS` int(11) default NULL,
`ALL_LISTINGS` int(11) default NULL,
`isDefault` int(11) NOT NULL default '0',
`ALLAREAS` int(11) default '0',
PRIMARY KEY (`ID`),
KEY `isactive` (`isActive`),
KEY `id` (`ID`),
KEY `adtype` (`AdType`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Now, what I'm trying to do is -:
SELECT * FROM glinks_Adverts,glinks_Advert_Relations WHERE ALLAREAS = 1 OR Advert_Relations.CatName = "British Columbia/Vancouver/Concrete/Cement Finishing"
How exacly would I go by this?
Basically - a bit of history as to why I'm trying to do this.
The "Advert" table just holds the advert (but can also have stuff like NEWS, ALLAREAS,etc. Then the "relation" table holds a list of the "categoires" this listing can show in.
I need to randomly select a value, but just can't get it working :/
TIA!
Andy