mysql

Adding Values to dropdown Menu box from MySql_Fetch_Array

Am attemtping to populate a dropdown menu with the results of my SQL query. The script functions, however I just am unsure of the syntax to add the results into the html dropdown menu. Currently it populates a table with the results. Here is my code: <?php require_once('Connections/database.php'); ?> <?php $q=$_GET["q"]; mysql_select_d...

about mysqldump export index info

mysqldump -u root -p123 --opt --quick --database search > ./test.sql i have used mysqldump export data & schema from db,but it seems didn't contains index infomation? how can i add this to export sql file? ...

Is Java.sql's getRow() thread safe?

Lets say I have a large number of threads inserting into a mysql database using Java.sql. After i perform an insert i would like to know the primary key of the record i just inserted. I could use getRow() on the ResultSet returned by the insert query. However, is this thread safe? Or should I fire off another select statement to f...

Running mysqldump through Python's subprocess module is slow and verbose

@cost_time def dbdump_all(): "导出数据库所有数据至当前目录下以年月日命名的sql文件" filename=datetime.datetime.now().strftime("%Y-%m-%d") cmd="""mysqldump -u root -pzhoubt --opt --quick --database search > ./%s.sql"""%filename args=shlex.split(cmd) p=subprocess.Popen(args) #stdout, stderr = p.communicate() #print stdout,stderr pri...

The best way to compare a database row with a submitted form data

Hi guys. I have a table with 8 fields and a corresponding form. When the form is submitted, I have the id of the record. What is the best way to check if data in any one of the fields has changed for that row? Should use the SQL route WHERE field1=$field1 AND field2=$field2 ..... AND ID=$ID or pull the row and compare each field w...

mysql sub_string replace?

Hi there, Is it possible in mysql to replace the first character of a cell with something else? eg I have 64123 64340 64067 0104 0240 0456 I need to replace all the starting 0's with 64 how could I do this? ...

Order of execution of ORDER BY and LIMIT in a MySQL query

Hello all I have a query like this where I want to display sorted records in a paginated format. This is my query. SELECT * FROM answers WHERE userid = '10' ORDER BY votes LIMIT 10, 20 The two arguments to LIMIT will be used for generating page-by-page display of records. Now, my problem is ORDER BY. How does MySQL execute this quer...

Shell script to backup databases of users

I have the shell script which first goes in home directory and backups all folders like OCT-13-2010/username/homebck.tar.gz and i also backups the database ,ef if i am in user1 folder then all my databases are like username_web and i use the following to backup mysqldump --skip-lock-tables -u sqluser -ppassword --skip-extended-inse...

Optimal image storing?

Possible Duplicate: manage uploaded files in database or file system? Hi! I'm currently developing a website I just want to know of it is more optimal to store images in a table(MySQL) or to store the reference to an image in the table ? In the latter, the image is stored in a directory in a server instead of SQL-database M...

How to calculate voting points in a Q&A website using MySQL query

Hello all I am trying to execute the following query SELECT a.userid, COUNT(a.id) AS count_answers, SUM(v.yes_vote) as total_up_votes, SUM(v.all_vote - v.yes_vote) as total_down_votes, CAST(COUNT(a.id) + SUM(v.yes_vote) * 4 - SUM(v.all_vote) AS SIGNED) AS voting_points FROM (answers a) LEFT OUTER JOIN answers_vote_count v ON r.id = v.a...

PHP/PDO: return query rows without foreach?

I am confused about this, I run a query such as foreach($dbh->query("SELECT * FROM ...") as $row) { ...do something with row() But when I var_dump $dbh it is a PDOstatement object. This leads me to two questions: How does foreach somehow resolve the object into separate rows? How can I store all rows in an array, like $arr = $d...

how to format variables before db to avoid errors

I am recieving errors like this one: _mysql_exceptions.ProgrammingError: (1064, "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 't Stop.mp3' LIMIT 1' at line 1") Because I am trying to compare a URL that exists in my DB to one in a variable before I...

How to debug Hibernate

Suppose I have a simple hibernate program. In this program having a hibernate query. How do I debug this query so that I can know which query elements have values and which do not. ...

Zend Db Table Double JOIN

Hello. I have two tables: 1. plan_payment_type: id plan_id 2. plan id payment_period It is Foreign key between plan_payment_type.plan_id and plan.id. In my code I know a $plan_payment_type_id. My task is to select payment_period. Steps: Select plan_id from plan_payment_type Select payment_period from plan with selected...

Find duplicates or more in Mysql, delete them except the first one inputtet.

I have a table with rows like id, length, time and some of them are dublicates, where length and time is the same in some rows. I want to delete all copys of the first row submitted. id | length | time 01 | 255232 | 1242 02 | 255232 | 1242 <- Delete that one I have this to show all duplicates in table. SELECT idgarmin_track, length ...

Mysql performance/optimization help

So this was a small site that got extremely popular very fast and now and im having major problems with the below sql query. I understand that my DB design is not great. I have text field for subjects and programs witch contains a serialized array and i search it using like. the below query takes about a minute. SELECT p.*, e.institut...

Fetching geo data from google API while creating new record on DB

Hey, I have an entity that one of it's members is the actual city, country that it was "created" - the user only gives me lat, long coordinates and I need to use the google API to reverse geocode the coordinates into city, country. My question - What is the best way to fetch that information? is it safe enough to use a 3rd party web se...

php make with 64bits mysql error(solaris 10)

I want to install php v5.x.x on my solaris 10. i also have installed mysql 5.x 64bits in my system alr. I have make the php configuration as below ./configure --with-apxs2=/usr/local/apache2/bin/apxs -with-mysql=/usr/local/mysql This work fine.however i proceed to make& install the php, it return the error complain for ELFClass64 in m...

Passing ID to another form

Hi, im trying to pass the information of a specific data to be edited in another form which is edit_doc.php. However, when i click "Edit" it doesnt seem to work. Only edit_doc.php opens but the information the does not appear. Is ther any mistake in the codes? Please help. [php] echo "<table border='1'> <th>File Reference No.</th...

MySQL Error? Where the syntax mistake?

Tried thus query with "SELECT *" instead of "DELETE FROM" and it worked perfectly. DELETE FROM `80dage_garmin_track` t1 WHERE EXISTS ( SELECT 1 FROM `80dage_garmin_track` t2 WHERE t1.Length = t2.Length AND t1.Time = t2.Time AND t1.idgarmin_track > t2.idgarmin_track ) MySQL Error: .#1064 - You have an error in your SQL syntax; chec...