| Showing entries 1 to 8 |
InSELECT,ORDER BYandGROUP BYloops, the flag is checked after reading a block of rows. If the kill flag is set, the statement is aborted.
While learning a new ORDER BY syntax recently, as a diligent architect/DBA I reviewed the documentation. What I also found in the SELECT syntax which I did not also know was the keyword DUMPFILE.
The SELECT Syntax from MySQL 5.1 Manual states:
If you use INTO DUMPFILE instead of INTO OUTFILE, MySQL writes only one row into the file, without any column or line termination and without performing any escape processing. This is useful if you want to store a BLOB value in a file.
It’s a shame there is no middle ground, where you get the features of OUTFILE (i.e. all rows), and the features of DUMPFILE (i.e. no heading)
A colleague at work asked me “how can I run a case sensitive select on a case insensitive table?” out of curiosity and for a moment I hesitated, then said, yeah why not :) ….
Below are two different approaches (one of which is quite inefficient) and if anyone has another way, better or worse, please do leave a comment with your suggested approach :).
Cheers,
Darren
Preparation
[Read more...]
mysql [localhost] {root} (test) > create table t1(a varchar(20));
Query OK, 0 rows affected (0.02 sec)mysql [localhost] {root} (test) > insert into t1 (a) values ('darren');
Query OK, 1 row affected (0.00 sec)mysql [localhost] {root} (test) > insert into t1 (a) values ('Darren');
Query OK, 1 row affected (0.00 sec)mysql
There is many ways to populate vales into a HTML select element. Here is one example I’ve come up with.
PHP Code Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<select size="1" name="szFooBar[]" multiple="multiple">
< ?php
$i=0;
while($obResults = mysql_fetch_row($saResults))
{
if ($_POST['szFooBar'] == $obResults[0])
{ $szSelectedValue[$i] = " selected=\"selected\""; }
else { $szSelectedValue[$i] = ""; }
printf("<option value=\"%s\"%s>%s\n",$obResults[0], $szSelectedValue[$i], $obResults[1]);
$i++;
}
?>
</select>
[Read more...]
There are lots of ways to select a random record or row from a database table. Here are some example SQL statements that don't require additional application logic, but each database server requires different SQL syntax.
SELECT column FROM table ORDER BY RAND() LIMIT 1
SELECT column FROM table ORDER BY RANDOM() LIMIT 1
SELECT TOP 1 column FROM table ORDER BY NEWID()
SELECT column FROM table ORDER BY RAND() FETCH FIRST 1 ROWS ONLY
Thanks Tim
SELECT column FROM ( SELECT[Read more...]
| Showing entries 1 to 8 |