sql strange, VSTUDIO and V4MD 4.3

Ivan Smahin ivan_smahin at paradigmasoft.com
Mon Jun 14 06:25:23 CDT 2010


Hello Christian,

Monday, June 14, 2010, 2:02:17 PM, you wrote:


> Le 14 juin 2010 à 08:50, Ivan Smahin a écrit :

>> Hello Christian,
> Hi Yvan,
>> 
>> Sunday, June 13, 2010, 5:28:18 PM, you wrote:
>> 
>>> ok only in Director...
>> 
>> BTW, this issues is fixed already
>> http://www.valentina-db.com/bt/view.php?id=4930
>> 
>> 
>>> but I have other problem :
>> 
>>> I have, for example, 
>> 
>>> "select recID, scrap from tableScrap where recID IN (7, 23, 1)"
>> 
>>> but I want records IN ORDER of "IN" : 7, 23, 1 and not 1, 7, 23
>> 
>>> do you have a solution ?
>> 
>> select recID, scrap from tableScrap where recID = 7
>> UNION
>> select recID, scrap from tableScrap where recID = 23
>> UNION
>> select recID, scrap from tableScrap where recID = 1;

> in this example, I have only 3 records, but, in practice, I can have 10000 records !!
> I only want save my order...

And  you  do something like "...IN (7, 23, 1, ... thousand times ...)"
???

It would be pretty slow query...

Ok, how do you know that you need exactly such order - 7, 23, 1 ...?
I  guess  you  get  that  recIDs from another queries. So you might do
something like this:

select recID, scrap from tableScrap where recID IN ( select RecID from
tableScrap where <your conditions>)

or even redesign it to join which is more speedy in most cases.

Anyway sort order in the result is undefined following sql-standard.
Valentina  do  a  lot  of tricks to run the query as fast as possible.
Some of them based on idea of undefined order.

To  get  some  particular order you should use "order by" clause.


-- 
Best regards,
Ivan Smahin 
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list