Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to write this SQL Statement?
Message
 
 
To
02/01/2003 12:11:54
F Bilo
Bilo Office
Fuyang, China
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00737372
Message ID:
00737393
Views:
21
>I have a old appliaction to be update.The program who develop this system think that he need a table can be add more field later, so he create a table like this:
>
>ID n(10), fieldname c(50), fieldvalue c(50)
>
>If there are 2 field now, the table's content will like this:
>
>ID     fieldname       fieldvalue
>__________________________________
>1      field1          value1 of 1
>1      field2          value2 of 1
>2      field1          value1 of 2
>2      field2          value2 of 2
>3      field1          value1 of 3
>3      field2          value2 of 3
>...
>
>
>My question is: How can i use a sql statement to transform this structure into a normal cursor ?
>
>field1         field2
>__________________________
>value1 of 1    value2 of 1
>value1 of 2    value2 of 2
>value1 of 3    value2 of 3
>....
3 SQLs:
1) Select ID, FieldValue as Field1 where FieldName = "Field1" into cursor curField1

2) Select ID, FieldValue as Field2 where FieldName = "Field2" into cursor curField2

3) select curField1.ID, Field1, Field2 from curField1 inner join curField2 on curField1.ID = curField2.ID into cursor curFinal
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform