I need to compare two different columns in a mysql WHERE statement. Within a view that I have created I have a column called E_ID and one called event. I need to SELECT from the view where the E_ID != $E_ID when event = $event.
So if $event = status and $E_ID = 1 the statement would select anything thats not got the same event and the same E_ID but it could return data that has the same E_ID and a different event.
Okay lets have some examples. Lets say I have this as my two variable:
$E_ID = '1';
$event = 'status';
Okay and now in the table is this;
E_ID event
1 status
2 status
3 status
1 gig
3 track
5 gig
As you cans the first row contains the data set in the variables so we don't want to return that. But the problem lies in E_ID as they can be the same if the event is different. So I want to return everything that does not have the E_ID of 1 when the event is status. It can however return data of the same E_ID and the same event.
What should be returned is this;
E_ID event
2 status
3 status
1 gig
3 track
5 gig
As you can see everything is returned but the row that has the data set in the variables.
Here's my query so far.
SELECT * FROM stream_view WHERE E_ID != '$E_ID'
Not really sure where to start so have struggled to figure it out myself
$E_IDWHEN event =$event. So if there are a few events such as gig, track and status it will return data that does not have the same E_ID for rows that have the same event