Want to implement such a read database function, how to do
This post was last edited by Bnhxy on 2014-01-07 20:49:05
For example, I have two watches.
Table game has columns Gameid,gamename
There's data inside.
1. Gameid=1, Gamename=a
2. gameid=2, Gamename=b
3. gameid=3, Gamename=c
Table News has Newsid,news_title,gameid
There's data inside.
1. Newsid=1, NEWS_TITLE=ABC, gameid=1
2. newsid=2, News_title=def, gameid=1|2
3. newsid=3, News_title=ghi, gameid=1|2|3
Finally want to output all the news_title about GAMENAME=B
In addition to using like, what other good way to output, or how to build a table can achieve the corresponding effect?
Share to: more
------Solution--------------------
Select N.news_title from Game G, News n where G.gamename=b and InStr (N.gameid,g.gameid) >0
------Solution--------------------
Select Game.gameid, news.news_title from game, news
where game.gamename = ' B ' and Find_in_set (Game.gameid, replace (News.gameid, '
------Solution--------------------
', ','))
If News.gameid is not 1,
------Solution--------------------
2
------Solution--------------------
3 in this format, but the format is more ideal
------Solution--------------------
Select Game.gameid, news.news_title from game, news
where game.gamename = ' B ' and Find_in_set (Game.gameid, News.gameid)