-2

I have two mysql queries first query having results

bookmark_id, is_fav, title

and second query have results like this

bookmark_id, is_deleted

Sometimes both have same results or may have different result in count

i want output like as

bookmark_id, is_fav, title, is_deleted

Can anybody give me idea, how to do this

Thanks

1
  • @AbdulManaf Please remove the link to w3fools. It's offending ;) Aug 12, 2014 at 9:51

1 Answer 1

0

By using joins you can able to get the result. think you have not done any research..

mysql> create table book(bookmark_id int primary key,is_fav varchar(10),title varchar(100));
Query OK, 0 rows affected (0.14 sec)

mysql> create table book1(bookmark_id int unique,is_deleted varchar(10));
Query OK, 0 rows affected (0.09 sec)

mysql> insert into book values(1,'comic','literature');
Query OK, 1 row affected (0.04 sec)

mysql> insert into book values(2,'short','philiosphy');
Query OK, 1 row affected (0.05 sec)

mysql> insert into book1 values(1,'comic');
Query OK, 1 row affected (0.06 sec)

mysql> insert into book1 values(2,'short');
Query OK, 1 row affected (0.07 sec)

mysql> select a.bookmark_id,a.is_fav,a.title,b.is_deleted from book a,book1 b where a.bookmark_id=b.bookmark_id;
+-------------+--------+------------+------------+
| bookmark_id | is_fav | title      | is_deleted |
+-------------+--------+------------+------------+
|           1 | comic  | literature | comic      |
|           2 | short  | philiosphy | short      |
+-------------+--------+------------+------------+
2 rows in set (0.00 sec)
3
  • i have three tables
    – Hitu
    Aug 12, 2014 at 8:07
  • you can use inner join SELECT column_list FROM t1 INNER JOIN t2 ON join_condition1 INNER JOIN t3 ON join_condition2 ... WHERE where_conditions;
    – Karthick
    Aug 12, 2014 at 9:05
  • @Hitu : Post your question properly with proper table structure. Aug 12, 2014 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.