• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL ORDER BY FIELD does not working in CI 2.1.0

#1
[eluser]foska[/eluser]
Code:
Error Number: 1305

FUNCTION ******.FIELD does not exist

SELECT `id`, `image`, `sex` FROM `users` WHERE `id` IN (28,35,40,34,33) ORDER BY FIELD (id,28,35,40,34,33)
here using $this->db->query();
Need help in this...


#2
[eluser]foska[/eluser]
hm... probably it`s hosting problem

#3
[eluser]prakash[/eluser]
do you want the results in order by id? if so use

Code:
SELECT `id`, `image`, `sex` FROM `users` WHERE `id` IN (28,35,40,34,33) ORDER BY id


#4
[eluser]foska[/eluser]
[quote author="prakash" date="1340102509"]do you want the results in order by id? if so use

Code:
SELECT `id`, `image`, `sex` FROM `users` WHERE `id` IN (28,35,40,34,33) ORDER BY id

[/quote] Yes, but I want to save original ordering, as in "where in" section

#5
[eluser]prakash[/eluser]
if your number of records are less you can go with

Code:
SELECT `id`, `image`, `sex` FROM `users` WHERE `id` IN (28,35,40,34,33) ORDER BY id='28',id='35',id='40',id='34',id='33'

#6
[eluser]foska[/eluser]
it was problem in space between FIELD and ()... Now working Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.