Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to retrieve data from 3 tables at time in Sql Server
Message
 
 
À
22/01/2006 23:50:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01089270
Message ID:
01089329
Vues:
30
Hi Abdulla,

First, your message almost impossible to understand because all the formatting, you intended to have, got lost. You can use < pre>/< /pre> tags (w/o spaces) to preserve formatting.
It seems that something is wrong with you database design. Why not create one lookup table with all the codes/description end one extra column indicating the type of code? Using empty value to represent cash transactions doesn't look right to me either. If you not in control of table structures than you can build lookup table I described as a derived table and than join it with the transaction table.
SELECT tr.*, cd.Description  
	FROM transactions tr
		JOIN (
		
			SELECT Code, Description FROM Stock 
			UNION ALL ;
			SELECT Code, Description FROM NonStock 
			UNION ALL ;
			SELECT Code, Description FROM General 
			UNION ALL ;
			SELECT '', Cash  ;
			INTO CURSOR crsCodes READWRITE
		) cd		
		
		ON cd.Code = tr.TrsCode 
>I have 3 master tables and 1 tranasaction table
>
>In transaction table conatines eigther on of the code from Master file code or empty code;
>my purpose is while retriving data from Transaction Table i want to display description from master
>file with respect of the code from trasction table and if code is empty i want disply as 'CASH'.
>how i will do this in Sql Server.
>
>Master file 1 Stock. Master file 2 NonStock. Master file 3 General.
>STCODE1              NSTCODE1                GENCODE1
>STDESCRI             NSTDESCRI               GENDESCRI
>
>STCODE2              NSTCODE2                GENCODE2
>STDESCR2             NSTDESCR2               GENDESCR2
>
>Transaction file
>
>TrsInv              TrsCode          Amt       Qty
>
>INV001              STCODE1          5          7
>INV001              STCODE2          2          8
>INV001              GENCODE2         8          4
>INV001              NSTCODE1         8          4
>INV001                               6          9
>INV001              NSTCODE2         8          3
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform