473,464 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MySQL question - using IN()

Whey you use the IN() option in a mysql query is it possible to have the
records selected in the order in which they appear in the IN string?

Thanks

Hamilton
Jul 17 '05 #1
2 1491
Spidah <h.*********@eggstra.co.nz> wrote:
Whey you use the IN() option in a mysql query is it possible to have the
records selected in the order in which they appear in the IN string?

Thanks

Hamilton


<http://dev.mysql.com/doc/mysql/en/String_functions.html>:
FIELD() or FIND_IN_SET()
--
Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle
Jul 17 '05 #2
Spidah wrote:
Whey you use the IN() option in a mysql query is it possible to have the
records selected in the order in which they appear in the IN string?


Something like this should work:

SELECT ...
FROM ...
WHERE Field IN (x,y,z)
ORDER BY CASE Field
WHEN x THEN 1
WHEN y THEN 2
WHEN z THEN 3
END

--Mike
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: das dsf | last post by:
Hi there! I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the mysqld daemon up and running. But when I look at the output of phpinfo() , I do not see it there, which is...
7
by: atlasyeo | last post by:
Hi, my first time posting on a newsgroup. anyway, let's cut to the chase. I'm trying to migrate mysql database form one server to another server. So I copied the data from /var/lib/mysql to the...
2
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py...
0
by: Eduardo Pérez Ureta | last post by:
I'm looking for an easy way to use mysql from user (no root, no mysql system account) space. I don't want the user of my application to have to use a password to connect to the database. I want to...
0
by: sanjay gupta | last post by:
Hi All, I have recently installes mysql -4.0.0.1 on my redhat 7.1 machine . After installing when enter into mysql it gives me message " Access denied for user root@local host .......using...
3
by: lesiox | last post by:
Hi I wrote some GUI to connect to MySQL. I need add,edit,delete records - nothing hard. I'm using ODBC to connect to MySQL. I can add records, but when i try edit them or delete i have error:...
2
by: Shashikant Kore | last post by:
Hi, I am using MySQL for a table which will have 100M+ records, avg length of records being 130 bytes. When the number of records reach approx. 25M (and the file size close to 4GB), the rate of...
4
by: Dave Moore | last post by:
Hi All, I'm putting a website together using PHP and a MySQL database. I've been using phpMyAdmin as it makes updating the DB nice and easy. For development, I've been using Apache, MySQL and PHP...
3
by: Steven Sinfield | last post by:
Hi All, I am trying to use PHP & MySQL over SSL, my issue is that the data that I am querying also needs to be available by non-secure as well. Can someone please help me in doing this. ...
2
by: GS | last post by:
Implemented web application using MySQL to maintain inventory of the office PC's/laptops/Routers/hubs and other stuff, here we are using MySQL as back-end Database on Linux Operating system. I need...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.