Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to come up with a view/CA model
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01410693
Message ID:
01410725
Vues:
33
>>>>>>>No, only if I already have records for such models in my table.
>>>>>>
>>>>>>Sure.
>>>>>>
>>>>>>I know understand what you want(I think so)
>>>>>>Correct me if I'm wrong. You want to get ALL the selected models and IF some of them missing in That table to add them before the result is shown to user?
>>>>>
>>>>>Yes, exactly. And also somehow have a way to select models without a need for 100 parameters (have it dynamic).
>>>>
>>>>You have Models table isn't it?
>>>
>>>Yes.
>>>
>>>I've created a form with a textbox at the top to select an Option.
>>>
>>>Bellow is a first mover to select makes.
>>>
>>>Bellow is the second mover to select models (based on selected makes).
>>>
>>>So, the second mover destination will have several models selected.
>>>
>>>Now, bellow I need to show a grid with selected information and allow a user to enter price information.
>>>
>>>That's the brief idea.
>>
>>
>>
>>*** 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.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform