Intent: You simply needed.

 
Venezia: 00:46 aradapilot_: in that case, you can just add the conditions from the second into the where clause of the first

Venezia: 00:47 aradapilot_: SELECT * FROM user LEFT JOIN userfield ON user.userid = userfield.userid WHERE userfield.fieldX LIKE ‘%Value%’ and user.usergroupid NOT IN ‘1’,’2′ AND user.membergroupids NOT LIKE ‘2,%’ AND user.membergroupids NOT LIKE ‘%,2,%’ AND user.membergroupids NOT LIKE ‘%,2’;

Venezia: 00:47 aradapilot_: select user.field1,user.field2. really, select * is crappy

Venezia: 00:47 aradapilot_: !t intent evil

Venezia: 00:47 aradapilot_: aw no bot

Venezia: 00:47 aradapilot_: http://www.p****error.com/blog/select-*-is-evil

Senion: Intent: Sorry. I mean your first query.

Aiello: Venezia: Don’t do that.

Arcand: Intent: You should start by learning about outer joins before you make more mistakes.

Guercio: LEFT OUTER JOIN then?

Venezia: Sorry about the paste

Venezia: Intent: well, inner join, based on your condition

Venezia: Unless you intended something else

Scheidel: Intent: Read about outer joins. You don’t seem to understand how to use them.

Sallah: Basically, I am finding all the ‘userid’ in the ‘user’ table based on the ‘userid’ in the ‘userfield’ table where ‘userfield.fieldX’ is like’%Value%’

Silago: Xgc: for that, the query I have works. Can you let me know what specifically I should read about?

Mclaurine: Intent: In what way does your LEFT JOIN use work?

Formanek: Xgc: in the sense that I get the results I’m expecting from it

Wassenberg: Intent: Explain your logic.

Musse: Intent: Explain why you used LEFT JOIN. What specifically about that operation did you need?

Lundy: 1. I search for all rows in ‘userfield’ where ‘fieldX’ is like ‘%Value%’, 2. For all rows that are a match, I take their ‘userid’. 3. I left join that to the ‘userid’ in the ‘user’ table, and from all those, I search for those which do not have the further matches

Quach: Intent: What does LEFT JOIN do?

Slauson: Venezia: actually, this is going to end up being an update query, I’m just using the select to test

Schoenfeld: Xgc: in this case, to my understanding, is returning all the rows in one table with userids that match the other table given the criteria

Vallee: Intent: Inner join does that. Outer join does something more.

Bleyl: Xgc: I will read up on the differences

Skomo: Venezia: that worked, thanks it also worked with inner join. To do an update, with something like this work: UPDATE user INNER JOIN userfield ON user.userid = userfield.userid WHERE userfield.field8 LIKE ‘%Female%’ and user.usergroupid NOT IN ‘1’,’2′ AND user.membergroupids NOT LIKE ‘2,%’ AND user.membergroupids NOT LIKE ‘%,2,%’ AND user.membergroupids NOT LIKE ‘%,2’ SET membergroupids CONCATmembergroupids, ‘,Z’;

Schmandt: Xgc: I think I get it. I want to join, because I’m only interested in pulling the values that are identical, Since my next query acts on only those that are the same

Leard: Outer join also gives me extra data for all the matching rows in the left table, so it is excessive

Marmolejo: Intent: Correct. Now the next part, try to understand why you don’t need the derived table at all. Just add to the WHERE clause.

Weaving: Intent: All you wanted is to restrict the result further, That’s done with WHERE initial criteria AND additional criteria

Shakin: Intent: Look at the form of an UPDATE statement. You just need to use the proper form.

Stidd: Xgc: I’m trying to understand what you mean by not needing a derived table, But I’m not understanding where the derived table is in that query.

Wassenaar: Intent: You asked how to apply the second query to the result of the first query. You didn’t need to do that.

Roselle: Intent: You simply needed to include the logic in the WHERE clause, as you actually did in the UPDATE. The only problem is you have illegal Niedzwiedzki.