If I want to do a check a name, I want to see how many rows/name exists in the "username" column under users table. Lets say thousands ... hundred of thousands, should I use:
count(name),
count(*) or
SELECT username FROM users where username = 'name'
Which one is the more appropriate? Or they will give same result in term of speed/...
Basically I need to connect to the database without any existing databases. In SQL, there was "master" table that still exists. I would need to create the database programatically, therefore I need to connect to the database itself.
...
Hello everyone. MySQL connection in PHP can be established in two ways:
$mysql = new mysqli('localhost', 'user_name', 'password', 'database_name');
or
$link = mysqli_connect('localhost', 'user_name', 'password');
mysqli_set_charset($link, 'utf8');
mysqli_select_db($link, 'database_name');
Which one is better?
...
I'm trying to SELECT two values in one statement instead of two statements. The first statement counts how many entries won for a specific contest that has an id of 18. The second statement counts the total quantity of prizes for that contest.
Query 1:
SELECT
COUNT(*) FROM entries
WHERE entries.contest=18
AND entries.won=1
Query...
Hi everyone !
Here is my SQL request on MySQL (MySQL: 5.0.51a). I want have a list of restaurant with his cheaper menu:
select r.id, rm.id, rm.price, moyenne as note,
get_distance_metres('47.2412254', '6.0255656', map_lat, map_lon) AS distance
from restaurant_restaurant r
LEFT JOIN restaurant_menu rm ON r.id = rm.restaurant_id
wh...
Hi,
We are launching a website (paid subscription) and the sign up process includes entering an activation code. Activation codes are printed on scratch cards and sold via offline channels. Some of these cards are for 1 month access. Others are for 3 months and 1 year. Activation codes are unique 10-digit random numbers.
When the acces...
I want to create Database replication i try but some problem is there so give me full stap of How To Set Up Database Replication In MySQL
...
I am working on an application where users 'fight' to own larger parts of the map. Each map is made of a 1000 regions. Now my initial plan was to store the areas a user owns as a comma separated string e.g
a user owns regions one to ten
1,2,3,4,5,6,7,8,9,10
Problem is a user could potentially own all 1000
which means it could be a str...
Mission
I'm trying to find out the count of children in a set of tables illustrated below. The enviroment is LAMP but help in the right direction via other syntaxes are appreciated.
Table structure
users
-----
user_id
parent_id
user_meta
---------
user_id
registration_date
user_levels
-----------
user_id
level
This basic struc...
I dont know where my error is in this mysql query
$sql = "INSERT INTO `events` ( `owner` , `title` , `tagline` , `location` , `street` , `citytown` , `startdate` , `enddate` , `active` ) VALUES( '{$username}' , '{$data[title]}' , '{$data['tagline']}' , '{$data['location']}' , '{$data['street']}' , '{$data['citytown']}' , ...
I am using a MySQL Nested Set approach to store the classification of the various products that are sold on the website. I am looking for a nice javascript library to help out with rendering the tree from the nested set approach. I also need a good javascript drag and drop script to re-arrange and update the MySQL table.
Are there any g...
Hi,
I have a contest running, and to look at the results I've made this short code:
date_default_timezone_set('America/New_York');
echo "Results tallied at ". date("g:i:s A")."<br /><br />";
$names = array('contestant1','contestant2','contestant3'...); //10 entries
$plots = array();
foreach ($names as $name) {
$query = $th...
I'm working on a blog migration from a custom built blog to Wordpress. One of the fields that Wordpress is looking for in the database is a date/time stamp set to GMT, which is 4 hours ahead of our time. So I basically need to take our date/time stamp (in YYYY-MM-DD HH:MM:SS format), and add four hours to it. I was looking at the MySQL c...
Hello,
I have problem with creating a simple MySQL trigger in C#.
I'm using StringBuilder to build the following command string:
DELIMITER $$
DROP TRIGGER /*!50032 IF EXISTS */ dbname.table$$
CREATE TRIGGER dbname.inserttrigger AFTER INSERT ON dbname.table
FOR EACH ROW BEGIN
...
END;
$$
DELIMITER ;
when I try cmd.executeNonQuer...
I'm using PDO to insert a record (mysql and php)
$stmt->bindParam(':field1', $field1, PDO::PARAM_STR);
$stmt->bindParam(':field2', $field2, PDO::PARAM_STR);
$stmt->execute();
Is there a way to know if it inserted successfully, for example if the record was not inserted because it was a duplicate?
Edit: of course I can look at the dat...
I have a 'price' variable that contains some integer number from a MySQL database.
I want to check how many numbers the 'price' variable contains, and add a space in the variable depending on how many numbers. See below:
Example:
If 'price' is 150000 I would like the output to be 150 000 (notice the space).
OR, if it is 19000 I would ...
How can i update multiple values in mysql ,
this didn't work
UPDATE test SET list=0,
price= 0.00 cprice= 0.00 WHERE test.id =3232
...
Hi.
while($row = mysql_fetch_array($qry_result)){
$price_to_show=$row['price'];
number_format($price_to_show, 0, ',', ' ');
echo $price_to_show;
Why doesnt the above give the space separator?
It outputs the same as before the number format, what is wrong here?
Thanks
...
Hi all, I hope this question is ok for Stack Overflow – If it’s not appropriate then let me know and I’ll remove if that’s the case.
Magento has been recently giving me the following error when I visit the shop on a windows machine:
SQLSTATE[HY000]: General error: 1
Can’t create/write to file
‘C:\WINDOWS\TEMP#sql_ac0_0.MYI’
(E...
Hello all, I have a function on my that has a delete button to erase comments. I have the button all linked up and ready to go. I just don't know what I should put on the 'delte.php' script I am creating, and what to tell it php wise to send to the db to make the status dead. as well as deleting the comment off of the page.
Thanks
...