Jump to content

Recommended Posts

What query needs to be written to fetch the data except the first record, the id is auto increment but if the users delete the first lowest id then second id must not be shown.

 

$tbl=new Model;
$sSqlQuery="select * from ".ACHIEVEMENTS_TABLE." WHERE achievements_lang='EN' AND 1=1";

 

Any Idea ???

Thanks for you reply but i don't need this mysql_insert_id

 

your or part worked but while using LIMIT 1,1

 

$sSqlQuery="select * from ".ACHIEVEMENTS_TABLE." WHERE achievements_lang='EN' LIMIT 1,1  ORDER BY id";

 

it shows from the second record but limit is 1, I need all other records except the first record, is that possible

 

Thanks

Sorry, it didn't worked

 

$sSqlQuery="SELECT COUNT(id) as ttl, * FROM ".ACHIEVEMENTS_TABLE." WHERE achievements_lang='EN' LIMIT 1,ttl  ORDER BY id";

 

What is ttl here, While I tried this on other table,

 

SELECT COUNT(co_id) as ttl, * FROM contact LIMIT 1,ttl  ORDER BY co_id;

 

it shows error

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM contact LIMIT 1,ttl  ORDER BY co_id' at line 1 

Ok, I used the field name still not working

 

 SELECT COUNT( co_id ) AS ttl, co_fname, co_lname
FROM contact
ORDER BY co_id
LIMIT 1 , ttl 

 

As far as i have understood about AS ttl, it is to count the total rows and store in ttl and limited to total rows, am I right ?

 

But it is showing the same error near ttl

Im afraid to say though that it won't always be reliable. There is nothing to stop mysql from reusing an index if its generated via auto_increment. auto_increment should not be relied upon for order.

 

Do you mean for long term running of the site it will not be reliable ?

 

What are other alternatives ?

 

I am already afraid...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.