Anyone have any SQL-fu (can be MySQL-specific) that will give me the indexes of set bits in an int, without using a procedure? How about with a procedure?
For example, given:
create table example (val int);
insert into example values (1), (2), (3), (4), (256);
I can see the set bits:
select conv(val, 10, 2) from example;
+---------...
Sometimes I have a datetime or timestamp columns in the database and, for example, I need to select all records with timestamp updated today.
I usually do it like this:
SELECT * FROM mytable WHERE CAST(TS AS DATE) = CURDATE();
SELECT * FROM mytable WHERE CAST(TS AS DATE) = '2009-11-01';
Also, it's possible to use DATE() function ...
Can anyone tell me what's going on here. I'm not sure why this code is not working and throwing the following error:
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 'AND role != 7 AND role != 4' at line 3
$sql = 'SELECT * FROM tblusers
INNER...
I have a program (flex) that queries a database and gets back a dataset (value, timestamp). In the program I then put each value in the set through an algorithm to get a new value resulting in all the values being transformed. Instead of having to do this transformation of data in my program I would like mysql to do it and send the res...
I was wondering what is the best way to store a users upload images like an avatar and so on using PHP and MySQL? Where should I begin? And is there a good article on this?
...
Using php to get results from a database using
$exe = mysql_query("SELECT * FROM info ORDER BY ID ASC");
echo 'table width="80%"';
while ($r = mysql_fetch_array($exe)) {
Then the table layout. So I am just getting a long long list of results. Is there anyway to after every 10 results make a break or put a line across?
...
The query remains constant, but the offset varies.
SELECT NAME from tbl WHERE alphabet_index='A' limit 880,1;
SELECT NAME from tbl WHERE alphabet_index='A' limit 1760,1;
SELECT NAME from tbl WHERE alphabet_index='A' limit 2640,1;
....
SELECT NAME from tbl WHERE alphabet_index='A' limit 34320,1;
Is there a better way to do this withou...
Hi,
I'd like to create a GViz of some data in a MySql Database and I'm having problems.
Here is the source so far:
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');
mysql_select_db($dbname);
$int_y_pos = -1;
$int_y_step_small = 1;
$sql = "SELECT * from table')";
$sql = mysql_query($sql...
when
$query = 'SELECT * FROM users';
and there are multiple columns/rows, does mysql_fetch_assoc($result)
return a two-dimensional array?
Can I draw each row by simply saying: array_pop(mysql_fetch_assoc($r))
thanks!
...
I am running MySQL server on the server's which has following specifications -
Dual Xeon Quad Core 2.0, 2048 MB RAM, 1x 160 GB SATA
Fedora Core + SSH
But MySQL process for inserting 10000 records take more than 100% of CPU and up to 1 GB of RAM.
It's a plain insert statement.
Why is MySQL is taking so much of memory and what can done...
I've developed an application that users can use to store lists of their favourite books, books they've read, books they'd like to read, etc., and it's all working fine, but it's just suddenly struck me that users may want to print off their list or download their list to use in another format such as a CSV file to import into a spreadsh...
I want to write a query to select from a table all rows with the word "piggy" in a column called Description.
SELECT * FROM table WHERE ...?
Thank you!
...
Hello,
I have a counter field in a myisam table. To update the counter value in a multitasking environment (web server, concurrent queries from PHP) I need to lock the record for update.
So I do it like this:
START TRANSACTION;
SELECT Counter FROM mytable ... FOR UPDATE;
UPDATE Counter value or INSERT INTO mytable;
// let's make s...
What can you tell about speed of couchdb and mysql databases?
I mean, very simple requests like getting one row (or one document) by unique id and simple requests like getting the 20 ids/rows/documents with the biggest date (of course, using indexes and views etc - don't really know how it works in CouchDB but I'm pretty sure there is s...
In by DB I have a table with a field called 'fk_ownerID'. By default, when I add a new table row, the 'fk_ownerID' is empty. In Toad for MySQL, this is shown as {null}. If 'fk_ownerID' is given a value, and I later remove this value, I set fk_ownerID = "".
Now, I have the following code:
$result = $dal->getRowByValue('tableName','id', ...
Hi everyone,
have an issue here of how to configure mysql (myisam) properly for the bulk insert (load data infile) to be performed fast.
There is 6 Gb text file to be imported, 15 mln rows, 16 columns (some int, some varchar(255), one varchar(40), one char(1) some datetime, one mediumtext).
relative my.conf settings:
key_buffer = 80...
I have two tables. Categories and products.(using codeigniter)
Categories
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`shortdesc` varchar(255) NOT NULL,
`longdesc` text NOT NULL,
`status` enum('active','inactive') NOT NULL,
`parentid` int(11) NOT NULL,
PRIM...
There is a query like SELECT * FROM clients ORDER BY id. I want to select only first 10 elements. How can I do this?
P.S. I'm using MySQL.
...
Hi folks, I want to make a summary of the main differences between all the Mysql engines and of course the most populars also.
And what criteria should I use to determine which engine to use?
Best to all,
...