fetch row from data failed

here is my three table data


– Table structure for table carbon_topics

CREATE TABLE IF NOT EXISTS carbon_topics (
ID int(11) NOT NULL AUTO_INCREMENT,
Topic varchar(255) NOT NULL,
Tags text,
UserID int(10) unsigned NOT NULL DEFAULT ‘0’,
UserName varchar(50) NOT NULL,
LastName varchar(50) DEFAULT NULL,
PostTime int(10) unsigned NOT NULL,
LastTime int(10) unsigned NOT NULL,
IsGood tinyint(1) unsigned DEFAULT ‘0’,
IsTop tinyint(1) unsigned DEFAULT ‘0’,
IsLocked tinyint(1) unsigned DEFAULT ‘0’,
IsDel tinyint(1) unsigned DEFAULT ‘0’,
IsVote tinyint(1) unsigned DEFAULT ‘0’,
Views int(10) unsigned DEFAULT ‘0’,
Replies int(10) unsigned DEFAULT ‘0’,
Favorites int(10) unsigned DEFAULT ‘0’,
RatingSum int(10) unsigned NOT NULL DEFAULT ‘0’,
TotalRatings int(10) unsigned NOT NULL DEFAULT ‘0’,
LastViewedTime int(10) unsigned NOT NULL,
PostsTableName int(10) unsigned DEFAULT NULL,
ThreadStyle varchar(255) DEFAULT NULL,
Lists longtext,
ListsTime int(10) unsigned NOT NULL,
Log longtext,
PRIMARY KEY (ID),
KEY LastTime (LastTime,IsDel),
KEY UserTopics (UserName,IsDel,LastTime)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;


– Table structure for table carbon_posttags

CREATE TABLE IF NOT EXISTS carbon_posttags (
TagID int(11) DEFAULT ‘0’,
TopicID int(11) DEFAULT ‘0’,
PostID int(11) DEFAULT ‘0’,
KEY TagsIndex (TagID,TopicID),
KEY TopicID (TopicID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


– Table structure for table carbon_tags

CREATE TABLE IF NOT EXISTS carbon_tags (
ID int(10) unsigned NOT NULL AUTO_INCREMENT,
Name varchar(255) NOT NULL,
Followers int(10) unsigned DEFAULT ‘0’,
Icon tinyint(1) unsigned DEFAULT ‘0’,
Description mediumtext,
IsEnabled tinyint(1) unsigned DEFAULT ‘1’,
TotalPosts int(10) unsigned DEFAULT ‘0’,
MostRecentPostTime int(10) unsigned NOT NULL,
DateCreated int(10) unsigned NOT NULL,
PRIMARY KEY (ID),
KEY TagName (Name) USING HASH,
KEY TotalPosts (IsEnabled,TotalPosts)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

===================================================

I want select topics from table carbon_topics AND only certain tag for example “tag1”

here is what I do
$sql = "SELECT carbon_topics.Topic, carbon_topics.ID, carbon_topics.Tags
FROM carbon_topics
WHERE carbon_topics.Tags = ‘​tag1’ ";

i think i failed

I don’t see anything wrong with that SQL Statement, why do you think you failed?

Do you have the table populated with test data and is there at least one that has tag1 in it?

Sponsor our Newsletter | Privacy Policy | Terms of Service