Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The Use of * In Sql Select Syntax
Message
 
To
10/03/2007 08:17:24
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01202512
Message ID:
01202515
Views:
13
>Hi guys
>
>I seem not to understand the proper use of the * in Sql Select Syntax especially where JOINS exist. How can I use it to select ALL FIELDS from the LEFT JOIN and just One or Two Fields from the RIGHT JOIN or Vice Versa. Whenever I use it, the output ends up will ALL fields from ALL Tables.
>
>Thanks in advance
>
>Fred Matano
CLOSE DATABASES ALL
CREATE TABLE MyParentTable (Id I,NameEmpl C(50))
FOR myCount = 1 TO 50
    INSERT INTO MyParentTable VALUE(myCount,TRANSFORM(myCount)+[abc])
NEXT

CREATE TABLE OtherTable (Id I,StockItem N(10),Field1 C(10))
INSERT INTO OtherTable VALUES(5,15,[sometext1])
INSERT INTO OtherTable VALUES(15,25,[sometext2])

INSERT INTO OtherTable VALUES(6,16,[sometext3])
INSERT INTO OtherTable VALUES(16,26,[sometext4])

INSERT INTO OtherTable VALUES(34,36,[sometext5])
INSERT INTO OtherTable VALUES(34,46,[sometext1])

SELECT MyParentTable.*,                                     ;
       OtherTable.StockItem                                 ;
  FROM MyParentTable                                        ;
  LEFT JOIN OtherTable ON MyParentTable.Id = OtherTable.Id  ;
  INTO CURSOR YourCrs
BROWSE NORMAL
Use TableName.* and not only *

Try with
SELECT *,                                                   ;
       OtherTable.StockItem                                 ;
  FROM MyParentTable                                        ;
  LEFT JOIN OtherTable ON MyParentTable.Id = OtherTable.Id  ;
  INTO CURSOR YourCrs
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst
Previous
Reply
Map
View

Click here to load this message in the networking platform