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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL to update table-1 based on table-2

Status
Not open for further replies.

UHsoccer

Programmer
Apr 24, 2003
139
US
Want to add to table-1 companies from table-2 and set several flags. In addition, I should not add if it would create a duplicate entry in Table-1

So,
Table-2 contains list of companyID's
Table-1 contain Flag-1, CompanyID and Flag-2

Here is the SQL code (that does NOT work)

Select compID from table-2
Insert into table-1 (flag-1, compid, Flag-2)
Values (6, compID, 271)

One mighjt suspect, I am not an SQL expert.

Thanks for the help in advance
 
What version of Crystal are you using.

This can't be done in CR 8.5 or below.

The SQL would look something like the following, though CR is going to want to return data:

Insert into table-1 (flag-1, compid, Flag-2)
select 6, compID, 271 from table-2

Crystal isn't a database programming language, it's designed to report on data, not massage it.

You might be better served using straight SQL in your database query execution program, or MS Access.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top