Jump to content

[SOLVED] SELECT over two tables with specifik values


agge

Recommended Posts

        TB1                                    TB2

u_ID Name Country                      n_ID    nick

1        A      USA                          1        A

2        B      AUSTRALIA                1        B

3        DA    SWEDEN                    3        C

4        C      USA                          4        A

5        FA    USA                        5          B

 

This is the SELECT formula I want to work:

 

SELECT * FROM TB1, TB2 WHERE name LIKE '%a%' AND nick LIKE '%a%'  WHERE country='USA';

 

If I split it up I get one to work:

SELECT * FROM TB1 WHERE name LIKE '%a%' AND country='USA';  -- This give me u_ID 1 & 5

but how to make the other one to work:

 

SELECT * TB2 WHERE nick LIKE '%a%* AND TB1.country='USA'; -- I doesnt work, but this is how I want it to work in some other code formula,  it should be n_ID 1 & 4 who is selected.

Remember, MySQL is case-sensitive. a lowercase a means something different than an uppercase A.

 

It reminds me of someone's signature on this board:

Capitalization is the difference between "I had to help my uncle Jack off a horse.." and "I had to help my uncle jack off a horse.."

I think this is the SQL you would want...

 

SELECT * FROM TB1 LEFT JOIN TB2 ON name=nick WHERE country='USA';

 

But I'm really not sure what this data is or what you're trying to do.

 

But when I use this SELECT name and nick must be the same, and that is not always in that way, n_ID 4, nick could be Abraham and there is no name wich fits thats in TB1, but it still assigned to country=USA, you know what I mean

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.