When you run a query like so:
$query = "SELECT * FROM table";
$result = odbc_exec($dbh, $query);
while ($row = odbc_fetch_array($result)) {
print_r($row);
}
Does the resource stored in $result point to data that exists on the server running php? Or is pointing to data in the database? Put another way, as the while loop does it's...
Is there a way I can return a set of mySQL rows in the order they're called. For instance, when I call this:
SELECT * FROM heroes WHERE id IN ( 41 , 48 , 38 , 14 , 47 , 44 ) LIMIT 6
I'd like the rows returned in that order. Is there a php function I could apply to the results afterward to achieve this ordering?
...
Hi All,
How can I import a mysql database dump file (contains insert and create table statements) programmatically through a java program. I need this as the setup phase of a unit test.
Unfortunately this doesn't work:
Connection conn = dbConnectionSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute(FileUtil...
I'm trying to find step-by-step instructions to run Ruby on Rails on MAMP server and use MAMP's mySQL database. I am on Snow Leopard also. I have read Hivelogic's article about this but I really don't want to compile rails, ruby and mySQL.
Anyone have any suggestions
...
I'm using Mysql with collation utf8_general_ci and for most of my searches it is good. But for one model and one field I want to find a record with case sensitive. How to do it?
...
I have ran into some problems with MySQL that causes our index cardinality to show up as "NULL". I have noticed that for an index with multiple columns, only the Last column has an actual cardinality value. I have written this query but I want to confirm that there is nothing that I am missing:
SELECT s.TABLE_SCHEMA,
s.TABLE_NAM...
I am trying to create a search for my website over a mySQL database. I started down the line of using Sphinx but was hesitant when learning that the index doesn't update in real time. I did see they have an almost real time update but I am concerned this doesn't fit my system well because new content is added to the database on a minute ...
In a MySQL table, I have several columns - some containing strings, some dates or numbers. I have always just made each field varchar(200). What are the benefits of creating more appropriate field types? Will select queries become faster?
...
Hi,
I have a MySQL database with two fields: Date and Value.
My dates are quarters (Q1-2007, Q2-2008...). I want to be able to use the following SQL query:
SELECT * FROM table WHERE 1 ORDER BY Date
How can I do this?
...
I have a table in my database containing football results, the relevant columns being matchNumber (a number based on the date), Result (either "W", "D" or "L") goalsFor, goalsAg and manager.
I have this query:
SELECT COUNT(*) AS P,
(SELECT COUNT(*) FROM match_results WHERE manager = 13 AND Result = "W") AS W,
(SELECT COUNT(*) FROM ...
UPDATE forms SET
pos = (SELECT MIN(pos)-1 FROM forms)
WHERE id=$id
This doesn't work, error message:
**You can't specify target table 'form' for update in FROM clause**
I hope it's clear: I want to get the minimal element-1 from the same table and assign it to pos
...
I have a table that uses 3 foreign keys into other tables. When I perform a left join, I get duplicate columns. MySQL says that the USING syntax will reduce the duplicate columns, but there aren't examples for multiple keys.
Given:
mysql> describe recipes;
+------------------+------------------+------+-----+---------+-------+
| Fiel...
What's wrong with:
$term = $_POST['search'];
function buildQuery($exploded,$count,$query)
{
if(count($exploded)>$count)
{
$query.= ' AND column LIKE "%'. $exploded[$count] .'%"';
return buildQuery($exploded,$count+1,$query);
}
return $query;
}
$exploded = explode(' ',$term);
$query = buildQuery($exploded,1,
'S...
Hello,
Sometime you have many relationships in a table, and you need to insert data. It becomes a painful task when you constantly have to go check the ids of your parent rows for each foreign keys.
Is there a tool that make this task easier, by allowing me to do a kind of ajax search for ids while I am inserting data?
For exemple, ...
Most sites that have some sort of user profile will either do something like this:
profile.php?u=123445
or else:
profile.php?u=jason.Davis
So I am curious, would it be slower to use a name to lookup a profile with php/mysql vs. using a number to look up a profile record?
...
Hello, Im new to kohana 3 here, and my understanding of it is very limited.
The problem is instead of displaying the first row, what code should I use when I'll try to get a random row from a certain table?
BTW: I'm using the ORM module.
Thanks
...
I have a table foodbar, created with the following DDL. (I am using mySQL 5.1.x)
CREATE TABLE foodbar (
id INT NOT NULL AUTO_INCREMENT,
user_id INT NOT NULL,
weight double not null,
created_at date not null
);
I have four questions:
How may I write a query that returns
a result set that gives me th...
Hello. I am looking for a development tool for working with MySQL Database. The must have features include reverse & forward engineering capabilities. One that I've liked is "ModelRight for MySQL" but it is weirdly overpriced. So I am looking for something free/open source or at least reasonably priced.
...
I have a MySQL table with an auto incremement id field. When I delete a row and then insert a new row, The id of the row I deleted is skipped and the new gets an id of one greater than the previous row. Is there any way I can prevent this? I would like the new row to just replace the old one. Is there an important reason why this hap...
I know it can be convenient for a programmer to group different sets of tables into different databases. Is a computational benefit to doing this?
...