I don't know, what are you talking about, but from your question I conclude this.
Let say A
and B
are two tables and their common fields are fee_id
.
Then try this.
select a.name,b.fee_id from A a,B a where a.fee_id=b.fee_id
Above query will return all the data from both table by checking fee_id
in both tables.
Now, as you said, you need ORDER BY
. Then, do something like.
select a.name,b.fee_id from A a,B a where a.fee_id=b.fee_id ORDER BY a.name DESC
If you want to show your information in DESC
order of name.
UPDATE
How to create view
create view viewname as (select * from table1)
Solution for your 1st question
Let say name
field is common between both table and you want those record in that view which are UNIQUE in both table. I mean, if table1
has one record, but same record is not present in table2
create view viewname as (select * from table2 UNION (select * from table1 where name not in(select name from table2)))
Example :
NAME | NAME |
------------- ----------------
ABC | ABC |
CDF | GHI |
It will return
NAME |
-------------
ABC |
CDF |
GHI |
Solution for 2nd question
You have provided this query in your question. And, i don't feel anything wrong in that.
SELECT source_id
FROM table1
WHERE source_id NOT IN (SELECT source_id from table2)
ORDER BY source_id DESC;