Well, I know there is a funciton mysql_fetch_array() and we can use it like this:
while ($row = mysql_fetch_array($result)) {
echo $row['name'] . "<br />";
}
But is there any other way? For example, if there is only one element that can be returned, and not an array.
Thanks)
...
Hi guys
I am a newbie to mysql. I am confused by the quotes signs.
In mysql query
Does it make any different between
CREATE DATABASE 'mydatabase';
and
CREATE DATABSE mydatabase
One with quote, the other without
Also with Insert and other commands
Thanks
...
Using openbravoPOS i got a mySQL database of all my producs tickets stock etc.
Products are in one table and the tickets are in another, so to make a query that get me all the products that are sold (and therefore are in ticketlines) are simple.
How do I make a query that gives me the products that are not i any ticketlines?
...
I HAVE TWO TABLES shown below
table_joining
id join_id(PK) transfer_id(FK) unit_id transfer_date joining_date
1 j_1 t_1 u_1 2010-06-05 2010-03-05
2 j_2 t_2 u_3 2010-05-10 2010-03-10
3 j_3 t_3 u_6 2010-04-10 201...
Hi, i've a problem for a table update. follow table structure:
Table1
tableid
...
...
productID_1
productID_2
productID_3
Table2
productID
Total
I've to totalize each product in table2.
For example:
SELECT COUNT(*) as tot, ProductID_1 FROM Table1 GROUP Table1
then the UPDATE table2 SET total =..??? (how can...
How do I write this?
Create a script that will retrieve the title of each books, the name of its publisher, and the first and last name of each author of the book.
SQL> Desc BOOKAUTHOR
Name Null? Type
ISBN ...
I know the title of this question is a bit confusing, so bear with me. :)
I have a (MySQL) database with a Person record. A Person also has a slug field. Unfortunately, slug fields are not unique. There are a number of duplicate records, i.e., the records have different IDs but the same first name, last name, and slug. A Person may also...
Retrieving last 10 row inserted without auto increment column as well as timestamp fields.?
...
I'm trying to create a single query which, similar to stack overflow, will give me the number of votes, but also make sure that the currently viewing user can't upvote again if they've already upvoted.
my query currently looks like
SELECT cid, text, COUNT(votes.parentid) FROM comments LEFT JOIN votes ON comments.cid=votes.parentid AND...
Alright, PHP is throwing this error at me (in the log) when I run the code mentioned below:
Error
mysql_num_rows() expects parameter 1 to be resource, string given in (place) on line 10
Line 9-11
$queryFP = ("SELECT * FROM db");
$countFP = mysql_num_rows($queryFP);
$aID = rand(1, $countFP);
I think it has something to do with the ...
Below is an over-simplified version of table I'm using:
fruits
+-------+---------+
| id | type |
+-------+---------+
| 1 | apple |
| 2 | orange |
| 3 | banana |
| 4 | apple |
| 5 | apple |
| 6 | apple |
| 7 | orange |
| 8 | apple |
| 9 | apple |
| 10 | banana |
+...
I have a mysql table with over 4 million of data; well the problem is that SOME queries WORK and SOME DON'T it depends on the search term, if the search term has a big volume of data in the table than I get the following error:
Fatal error: Allowed memory size of 1048576000 bytes exhausted (tried to allocate 75 bytes) in /home/****/pu...
i have around (1,049,906 total, Query took 0.0005 sec) in my x table ,
If i simply retrieve trying to retrive the particular field records ,
Its tooks hardly 6 mins ,
This is my query
SELECT CUSTOMER_CODE FROM X_TBL ;
CUSTOMER_CODE => UNIQUE
THE ABOVE QUERY TOOK 6MIN ,
Tel me optimization tips for this ,
Also in some situatio...
I have a table with over 4 million rows, I want to split this table in more tables, i.e one table with 50k rows.
I also need to perform a search on these tables, whats the best way to do it? with JOIN, or? do you have some better ideas?
Best Regards,
QUERY
$do = $this->select()
->where('branche LIKE ?',''.mys...
I have the following query which is takin 3 seconds on a table of 1500 rows, does someone know how to simplify it?
SELECT dealers.name, dealers.companyName, dealer_accounts.balance
FROM dealers
INNER JOIN dealer_accounts
ON dealers.id = dealer_accounts.dealer_id
WHERE dealer_accounts.id = (
SELECT id
FROM dealer_accounts
WHER...
I'm trying to query a database, and return a set of values. Part of the data i'm trying to return is an insurance premium breakdown.
Is it possible to run a query, that selects multiple fields, then adds then and returns them as a single value?
I've seen SUM() but the examples i've seen show it as adding up the results of an entire fi...
Hello !
When I try to execute following querry:
SELECT id_subscriber
INTO newsletter_to_send
FROM subscribers
I get an error:
#1327 - Undeclared variable: newsletter_to_send
What is wrong with that query ?
...
I'm trying to isolate duplicates in a 500MB database and have tried two ways to do it. One creating a new table and grouping:
CREATE TABLE test_table as
SELECT * FROM items WHERE 1 GROUP BY title;
But it's been running for an hour and in MySQL Admin it says the status is Locked.
The other way I tried was to delete duplicates with thi...
Hello! I'm investigating Zend Framework and currently stucked in counting resulting rows of sql query... Every method I try (from documentation and some blogposts and tutorials) returns an error (like Call to undefined function) or simply gives the incorrect value.
I've tried this:
$checkquery = $db->select()
->from('users', 'COUNT(...
Here is mysql data
id usr good quant delayed cart_ts
------------------------------------------------------
14 4 1 1 0 20100601235348
13 4 11 1 0 20100601235345
12 4 4 1 0 20100601235335
11 4 1 1 0 20100601235051
10 4 11 1 0 20100601235051
9 4 4 1 0 20100601235051
15 4 2 1...