|
| random record found in database table |
| Iniciado por guest, 04,ene. 2015 15:29 - 8 respuestas |
| |
| | | |
|
| |
| Publicado el 04,enero 2015 - 15:29 |
SELECT ExamData.ExamDataID AS ExamDataID, ExamData.Index_Id AS Index_Id, ExamData.ED_Que AS ED_Que, ExamData.ED_Ans_A AS ED_Ans_A, ExamData.ED_Ans_B AS ED_Ans_B, ExamData.ED_Ans_C AS ED_Ans_C, ExamData.ED_Ans_D AS ED_Ans_D, ExamData.ED_currectAns AS ED_currectAns FROM ExamData ORDER BY Index_Id RAND LIMIT 100
-------------------- i am try to above query excu. but this query in give error windev17
please give help me |
| |
| |
| | | |
|
| | |
| |
| Publicado el 04,enero 2015 - 15:40 |
Hi
1. What error ? 2. What code do you use to run this query? 3. On what type of database?
Are we supposed to devine all that?
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,enero 2015 - 06:26 |
database id hyperfile
does not generat query
error is unexpected word:RAND() |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,enero 2015 - 11:01 |
Hi Vijay ,
If you donnot give us more information we cannot help you.
Is there an error or does the query generate other results then you expect? How do you run the query, what code? Do you use hyperfile cs ?
Vijay you are a programmer. Then you know that for fixing bugs one first has to uderstand what you want to atchief. If an error is displayed then moast of the time you are doing something wrong, but it can be a windev bug as well. If there is no error but other results then you expect then you have to try to figgert out why this is. I often first try to run only the query , for instance in the hyperfile cs if you made the query yourself.
It is all about excluding things that are good an thus the fault remains and you can focus on that
You problebly know all this . But in my opinion far to often forum users post verry little info and expect a result form other users. If you spent the time and be as specific as possible you are moast likely get an answer for the users on this forum in general are verry helpfull en willing to help individuals.
regards Allard |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,enero 2015 - 11:09 |
Hi,
1. What does ErrorInfo(hErrFullDetails) tell you? 2. Do you have the hQueryWithoutCorrection parameter flagged? 3...
Cheers,
Peter H. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,enero 2015 - 11:18 |
VIjay,
I have never used this feature but I think there is no facility to randomize results of a Query in HFSQL. Generally in MySQL there is an SQL function RAND() so it would be possible to use it in ORDER BY clause of a select query.
Here is a sample query that I have used in retrieving and showin Ad in a website SELECT ad_content_image, ad_link, ad_id, ad_count FROM advertisement WHERE ad_approve = 1 AND ad_content_type_id = 1 AND (ad_lifetime = 1 OR DATE(ad_end_date) > DATE(NOW())) ORDER BY RAND() LIMIT 1 What you can do is retrieve data as usually one would using query and then populate the controls by accessing the data retrieved randomly.
HTH
Yogi Yang |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,enero 2015 - 12:08 |
Vijay
Your error explains the problem
RAND() is not supported in the HFSQL language.
2 options... 1. Change to a database that does support it (MySQL, MSSQL etc)
2. Load your query result into an array and use 'ArrayMix' - The type of array you choose depends the number of rows returned on how you need to display the result. A bit more work but an 'array of structures' would IMHO be the way to go
Just noticed: Item 2 requires version 19 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,enero 2015 - 13:36 |
You can try something like this: SELECT ExamData.ExamDataID AS ExamDataID, ExamData.Index_Id AS Index_Id, ExamData.ED_Que AS ED_Que, ExamData.ED_Ans_A AS ED_Ans_A, ExamData.ED_Ans_B AS ED_Ans_B, ExamData.ED_Ans_C AS ED_Ans_C, ExamData.ED_Ans_D AS ED_Ans_D, ExamData.ED_currectAns AS ED_currectAns, random() as ra FROM ExamData ORDER BY ra |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,enero 2015 - 14:35 |
| |
| |
| | | |
|
| | | | |
| | |
|