Instead of executing 2 slightly different sql statements to get a total of 10 results can it be done with just one select?
e.g
select a , b , c from mytable limit 3
select a , b , LEFT(100, c ) from mytable limit 3, 10
Instead of executing 2 slightly different sql statements to get a total of 10 results can it be done with just one select?
e.g
select a , b , c from mytable limit 3
select a , b , LEFT(100, c ) from mytable limit 3, 10
Check out UNION syntax
(SELECT a,b,c FROM mytable LIMIT 3)
UNION
(SELECT a,b,LEFT(100, c) FROM mytable LIMIT 3, 10);
Note the parentheses - these ensure the final LIMIT clause applies to the second query and not the whole result set.
Unless you've got a numeric key in the result which would let you use an IF to format the first n results differently, I don't think you're going to do this with a single select.
You can select all ten rows and then use a case statement to control what value is returned depending on a conditional statement you define.
set @line_total= 0;
select
a,
b,
@line_total := @line_total + 1,
(case when @line_total < 4
then c
else left(100, c) end)
from test_query limit 10;
http://dev.mysql.com/doc/refman/5.0/en/case-statement.html