Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Select the record from the query

New Here ,
Dec 22, 2008 Dec 22, 2008
<cfset myQuery = QueryNew("UserId, SelectedOptions", "Integer, Varchar")>

<cfset newRow = QueryAddRow(MyQuery, 2)>

<cfset temp = QuerySetCell(myQuery, "UserId", "1", 1)>
<cfset temp = QuerySetCell(myQuery, "SelectedOptions", "3,6,7,9", 1)>

<cfset temp = QuerySetCell(myQuery, "UserId", "2", 2)>
<cfset temp = QuerySetCell(myQuery, "SelectedOptions", "1,3,5", 2)>

<cfset temp = QuerySetCell(myQuery, "UserId", "3", 3)>
<cfset temp = QuerySetCell(myQuery, "SelectedOptions", "2,9", 3)>

Question: Find the UserId who has been selected the option number 3 or 5?
TOPICS
Getting started
271
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 22, 2008 Dec 22, 2008
LATEST
> <cfset temp = QuerySetCell(myQuery, "SelectedOptions", "1,3,5", 2)>

In the long run, the best answer is do not store delimited values: "1,3,5". You have already discovered one of the main reasons why: It is easy to insert the information but very difficult to query it. Your data should be normalized and separated into one row for each UserID and OptionID:

UserID, OptionID
2,1
2,3
2,5

Once you restructure, finding the answer to your question "Find the UserId who has been selected the option number 3 or 5?" will be easy.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources