0

I have a standard SELECT query as follows:

SELECT eid, title, content, thumb_image FROM diary ORDER BY eid DESC LIMIT 3

...and a SELECT SUBTRING query as follows:

SELECT SUBSTRING(content, 1, 200) FROM diary

I'd like to combine the two so that it selects the latest 3 entries in the table and displays them with a limit of 200 characters. At the moment I've tried the following which has proven to ignore all entries that are more than 200 characters:

SELECT eid, title, content, thumb_image FROM diary WHERE content IN (SELECT SUBSTRING(content, 1, 200) FROM diary) ORDER BY eid DESC LIMIT 3

I've tried multiple variations of putting the substring query next to where content is selected with little success:

SELECT eid, title, content IN (SELECT SUBSTRING(content, 1, 200) FROM diary), thumb_image FROM diary ORDER BY eid DESC LIMIT 3
SELECT eid, title, content IN (SELECT SUBSTRING(content, 1, 200)), thumb_image FROM diary ORDER BY eid DESC LIMIT 3
SELECT eid, title, content IN (SELECT SUBSTRING(1, 200)), thumb_image FROM diary ORDER BY eid DESC LIMIT 3

Some help would be great, I offer virtual high fives as a reward ;) and maybe some rep power ;)

2
Contributors
5
Replies
9
Views
9 Years
Discussion Span
Last Post by nav33n
1
SELECT eid, title, SUBSTRING(content, 1, 200), thumb_image FROM diary ORDER BY eid DESC LIMIT 3

:) Now, gimme my virtual high five!

Votes + Comments
Extremely helpful post ;)
0

*Venom Rush gives nav33n a virtual high five* ;)
Thanks a lot nav33n. Another rep point for you :cool:

0

Can't give u more rep nav33n. As much as I'd like to it's telling me I can't give you more rep today :|

I'll make a point of doing it tomorrow ;)

1

:(

LOL.. i know.. you have already given me reps for a php question(and you can give reps only once per day!)

Votes + Comments
ro matt mere shair :P ye le rep!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.