Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select records if field in 2nd table is in a list of val
Message
 
 
To
23/07/2007 17:29:51
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01242994
Message ID:
01242997
Views:
26
>Tables exist SQL2000 or SQL2005:
>
>I have 2 string values: thisform.pcInci_Id and thisform.pcParent_Id
>I want to pull all records from one table whose inci_id value exists in a result from another table
>
>
>Long Way:
>
>1.  Retrieve table1.inci_id field from all records in table1 where
>       table1.inci_id = thisform.pcInci_Id
>       or table1.inci_Id = thisform.pcParent_Id
>       or table1.parent_id = thisform.pcInci_Id
>       or (LEN(table1.parent_id)>0 AND table1.parent_id = thisform.pcParent_Id)
>
>2.  Get all fields in all records in table2 where
>       table2.inci_id is in (the cursor result created in step 1)
>
>
>For some reason I am stumped on the short way! Any ideas?
select * from Table2 where exists (select * table1 where
       table1.inci_id = thisform.pcInci_Id
       or table1.inci_Id = lnParm1  or table1.parent_id = lnParm2
       or (LEN(table1.parent_id)>0 AND table1.parent_id = lnParm2))
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform