Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query

Status
Not open for further replies.

parames

MIS
Jun 26, 2000
71
MY
Hello list,

I'm using mySql database and i have two tables.
In this two tables, there are two fields which are the same:
product and serial_no..
I want to do select sql query, which get the product and serial_no from this
two tables and transfer two another temp table..
Currently what i'm doing is, doing two sql queries for each table. So, this
temp table will have many duplicate records..
How to do this using one sql query and make sure no duplicate records??

*** records is this two tables might be same sometimes...

Thanks a lot..

Best Regards,
Parames.S

 
Hi,

I am not able to understand the condition u want to have is that u want to avoid duplicate records. Anyhow This scenerio can be handled with with Join(use the one which is approriate and then create a View(temp table) for select purpose.

Hope this should slove the problem.


Bye,
 
Hi

pls chk the foll query :
first create #temptable and then execute the below query with the specific coloumn name

insert #temptable(userid)select userid from table1 union select userid from table2

this will copy distinct records from table1 and table2. No duplicates. *** ASP/VB/SQL Programmer (Free Lancing work accepted) *** B-)
 
Hi

pls chk the foll query :
first create #temptable and then execute the below query with the specific coloumn name

insert #temptable(userid)select userid from table1 union select userid from table2

this will copy distinct records from table1 and table2. No duplicates.

HS :) *** ASP/VB/SQL Programmer (Free Lancing work accepted) *** B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top