Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to come up with a view/CA model
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01410693
Message ID:
01410737
Views:
34
This message has been marked as a message which has helped to the initial question of the thread.
>>>>
>>>>*** SelectCmd
>>>>SELECT ISNULL(YourTable.OptionID,?m.selOptionID) AS OptionID,
>>>>       ISNULL(YourTable.MakeId  ,?m.selMakeID)  AS lMakeID,
>>>>       ISNULL(YourTable.ModelId  ,Models.Id)    AS ModelId,
>>>>            rest of the fields
>>>>FROM YourTable
>>>>FULL JOIN Models ON YourTable.ModelId = Models.Id AND CHARINDEX([_]+CAST(Models.Id as varchar(20))+[_] , ?m.lcModels) > 0
>>>>WHERE YourTable.OptionID = ?m.selOptionID AND
>>>>             YourTable.MakeId   = ?m.selMakeID   AND
>>>>            CHARINDEX([_]+CAST(YourTable.ModelId as varchar(20))+[_], ?m.lcModels) > 0
>>>>
>>>>m.selOptionID = 1
>>>>m.selMakeID  = 12
>>>>lcModels       = "_1_7_12_225_"
>>>>
>>>
>>>
>>>SELECT ISNULL(YourTable.OptionID,?m.selOptionID) AS OptionID,
>>>>       ISNULL(YourTable.MakeId  ,?m.selMakeID)  AS lMakeID,
>>>>       ISNULL(YourTable.ModelId  ,Models.Id)    AS ModelId,
>>>>            rest of the fields
>>>>FROM Models LEFT JOIN myTable on Models.ID = myTable.ID and myTable.MakeID = ?lnMakeID
>>> where cast(Models.ModelID as varchar(20)) $ ?lcModels
>>
>>
>>??????????
>>No. WHERE clause should be in WHERE not in JOIN
>>BTW isn't it SQL Server?
>>And not LEFT but FULL join.
>
>VFP table. And I think the last select I posted should do it.

Then why in your post DB is set to SQL Server? :-)))))))))))))))))
O!!!!!
I just saw that you reverse FROM and JOINed tables :-))))))))))))))

Two things:
Put OptionsId also in JOIN condition (I didn't see it)
Use [_1_12_] pattern because when you want ModelId 1 you will get ALL that have [1] in the number 1, 10,11..19,21 etc.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform