mysql - SELECT UNTIL in sql

前端 未结 3 1094
慢半拍i
慢半拍i 2020-12-11 10:55

I want to select rows until I found a certain value and it\'s not numeric so I cannot use > or <. How can I do this ?

Example :

-----
Value
----         


        
3条回答
  •  感动是毒
    2020-12-11 11:24

    You can just use an equality comparator in the query, to directly search the value you're looking for.

    Why would you want to loop through your database until you found it when you can just specify what you're searching for ?

    You didn't give an example of what value it is you're searching for, so if it is a string

    Select x.* from table x WHERE x.Column = 'String Value'
    

    However, if you do want to put some extra load on your database (which it is in this undefined case), you'd have a stored procedure, looping through ID's stored in the database.

    For that, take a look at the following post, which might give you some inspiration : SQL LOOP INSERT Based on List of ID's

提交回复
热议问题