Reputation: 161
I have two tables, that I made second one Table B
from first one Table A
because first table had 52 columns for every book and I did not need them all and from other hand, more than 100000 rows was unusable.
I have 12 columns for every book in table B
.
table A contains some more information about books, like, published city
, cover kind
, etc...
Now, I need to have another field in second table ---> Table B
or in a new one.
This is my logic :
for each isbn
in table B
, I need to fetch a column named city
.
May be like this :
foreach isbn in table B,
fetch `city`, `weight`, `price` from table A
I tried this query :
select `isbn`, `weight`, `city` from `database1`.`table1` WHERE
(SELECT `isbn` from `database2`.`table2`);
but it seems it's not a right way.
Would you please help me to find right way to do this using SQL???
Thanks in Advance
Upvotes: 1
Views: 875
Reputation: 1841
You could simply join the two tables:
SELECT t1.isbn, t1.weight, t1.city
FROM table1 t1
JOIN table2 t2 ON t1.isbn = t2.isbn;
Upvotes: 1