Jump to content

[SOLVED] Extend query to list


EQaddict37

Recommended Posts

SELECT changelogs.ActivityId, changelogs.TimeHappened, userInfo.firstName, userInfo.lastName, changelogs.FormId,changelogs.BuildId, changelogs.GameId, changelogs.message   //SELECT log information

FROM changelogs 							      //FROM these tables
INNER JOIN userInfo 
	ON userInfo.UserId = changelogs.UserId 

WHERE 
(
changelogs.FormId=(SELECT FormId From FormInfo Where FormNumber="2GF+V") //if correct FormNumber
AND                                                                      //AND
(ActivityId=7 OR ActivityId=8 OR ActivityId=9 OR ActivityId=10)	         //A relevant activity
) 
OR									      //OR
(
changelogs.GameId=(SELECT GameId From GameInfo Where Name="013s") 	 //if correct Game
AND 								      	 //AND
(ActivityId=11 OR ActivityId=12)					 //A relevant activity
) 
OR 									      //OR
changelogs.activityId=0 						      	 //Adminitrator broadcast

order by logid DESC LIMIT 100 						      //ordered from newest to oldest

 

 

This is the query I have com up with that worked fine with one form or one gameId, however I need to beable to put in Multiple of either or both.

 

I tried just changing to

WHERE FormNumber ="2GF+V" OR FormNumber ="2GG+V"

.  However that returns a "Subquery returns more than 1 row" Error. After looking at that i am not quite sure, because I have in the past done a query where  "table.column = (query returning single column list)" and it worked.

 

 

 

Edit:

 

I remember a second latter....IN

 

SELECT changelogs.ActivityId, changelogs.TimeHappened, userInfo.firstName, userInfo.lastName, changelogs.FormId,changelogs.BuildId, changelogs.GameId, changelogs.message   //SELECT log information

FROM changelogs 							      //FROM these tables
INNER JOIN userInfo 
	ON userInfo.UserId = changelogs.UserId 

WHERE 
(
changelogs.FormId IN (SELECT FormId From FormInfo Where FormNumber="2GF+V" OR FormNumber ="2GG+V") //if correct FormNumber
AND                                                                      //AND
(ActivityId=7 OR ActivityId=8 OR ActivityId=9 OR ActivityId=10)	         //A relevant activity
) 
OR									      //OR
(
changelogs.GameId IN (SELECT GameId From GameInfo Where Name="013s") 	 //if correct Game
AND 								      	 //AND
(ActivityId=11 OR ActivityId=12)					 //A relevant activity
) 
OR 									      //OR
changelogs.activityId=0 						      	 //Adminitrator broadcast

order by logid DESC LIMIT 100 						      //ordered from newest to oldest

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.