Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL syntax
Message
From
26/06/2018 17:35:28
 
 
To
26/06/2018 17:24:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Miscellaneous
Thread ID:
01660886
Message ID:
01660889
Views:
41
>>Hi,
>>
>>I am again struggling with a SQL statement, with my code I get error "Queries of this type are not supported" -
>>Anybody to help me with the correct syntax? I suppose the two times where are a problem. However I can't find a correct solution to get to the by me desired result.
>>
>>
>>CREATE CURSOR curNames (ID i, firstname c(10), lastname c(10))
>>INSERT INTO curNames values ( 1, "Koen", "Piller")
>>INSERT INTO curNames VALUES ( 2, "John", "Brown")
>>INSERT INTO curNames VALUES ( 3, "Karl", "Johnson")
>>INSERT INTO curNames VALUES ( 4, "Donald", "Sutterland")
>>INSERT INTO curNames VALUES ( 5, "Bill", "Gates")
>>
>>CREATE CURSOR curGroupmember (ID i, iName i, iGroup i)
>>INSERT INTO curGroupmember VALUES (1, 2,1)
>>INSERT INTO curGroupmember VALUES (2, 3,1)
>>INSERT INTO curGroupmember VALUES (3, 3,2)
>>INSERT INTO curGroupmember VALUES (4, 1,2)
>>
>>CREATE CURSOR curGroup (ID i, Name c(10)
>>INSERT INTO curGroup VALUES (1, "Groupa")
>>INSERT INTO curGroup VALUES (2, "Groupb")
>>
>>- not working SQL statement: 
>>
>>TEXT TO m.lcSql pretext 1+2+4+8
>>SELECT T1.firstname, T1.Id 
>>FROM curnames T1
>>where UPPER(T1.Firstname) like  ? m.lcLetter + '%'
>>and 
>>curnames.id in 
>>(SELECT distinct(curNAMES.Id ) FROM curNAMES 
>>INNER JOIN curGROUPMEMBER T3 ON T3.iName = T1.ID 
>>INNER JOIN curGROUP T4 on T4.Id = T3.iGroup where T4.Id = ? m.liGroup ) 
>>INTO CURSOR junk READWRITE NOFILTER
>>	ENDTEXT
>>&lcSql
>>
>>lcLetter = "K"
>>liGroup = 2
>>
>>TEXT TO lcSQL PRETEXT 1+2+4+8
>>I would like to have:
>>
>>fullname	ID
>>Karl		3
>>Koen		1
>>ENDTEXT
>>
>>
>>Regards,
>>
>>Koen
>
>Probably you should instead tell us the logic and what you really want. I wouldn't expect to see "Karl" in result list? Why you have it? Also joining curGroups is unnecessary.
>
>If Karl weren't in the list I would say:
>
>
>lcLetter = "K"
>liGroup = 2
>
>Select T1.firstname, T1.Id ;
>	FROM curNames T1 ;
>	INNER Join curGroupmember T3 On T3.iName = T1.Id ;
>	where Upper(T1.firstname) Like  ?m.lcLetter + '%' ;
>	and T3.iGroup = ?m.liGroup  ;
>	INTO Cursor junk ;
>	READWRITE
>
>browse
>
Cetin,

Grrr, excuse me, my mistake in the example, the third line should read INSERT INTO curGroupmember VALUES (3, 3,2)

The logic:

The part SELECT T1.firstname, T1.Id FROM curnames T1 where UPPER(T1.Firstname) like ? m.lcLetter + '%'

would give a cursor with all the Firstnames from curNames with a starting letter like m.lcLetter viz 'Karl' and 'Koen'

and the second part should select only those names from curName where the group is 2

Sorry for confusion,

Koen
Previous
Reply
Map
View

Click here to load this message in the networking platform