mysql

Python MySQL: clean multiple foreign keys table

Hi Everybody, I am working with Python MySQL, and need to clean a table in my database that has 13328 rows. I can not make a simple drop table, because this table is child and also father of other child foreign-keys linked on it. If I try drop table, the system forbidden me. The table is defined with ON UPDATE CASCADE, ON DELETE CASCAD...

MySQL: CAST requires no space before parenthesis?

In MySQL 5.1, why won't this SQL work correctly? SELECT CAST (20091023 as date); [I've just figured out the answer to this question myself-- and I'll answer it myself below-- but the behavior was so odd that I wanted to capture it as a StackOverflow Q&A pair so others won't waste time on the same problem.] ...

Sync DB between Windows Mobile and MySQL

I am trying to create a windows mobile application that contains a database and can occasionally be connected to the Internet. When connected, I would like to sync the local database with the central database server. The central server is a MySQL server. The local database can be anything (probably SQL Compact). What I did so far: Ins...

MySql table type, how do I draw column data from one table to another automatically?

I have a 2 tables called 'members' and 'users' that both have 2 columns: name & gender. I want that everytime I add a new 'name' to members table, the value in 'gender' column in that row would be updated from 'users' table: **users:** Emilia - F John - M David - M **members:** Synthia - F 'INSERT INTO members VALUES('David')...or what...

internationalization of php website

Hi, I am currently working on a project / website and I will need to make it available in several languages. The site was done with PHP / mysql and a lot of javascript (jQuery). I have no idea where to start and I was hoping somebody could give me some hints. I would like to know opinions about what is the best approach to take, if ther...

how do i get mysql warning messages in php (not error)

hi all, i want to execute a sql at php which does something like changing a text column into int column. however, this sql failed to fun at php and succeeds in my mysql admin tool (sqlyog). server responses "1 row(s) affected. 1 warning(s)". but "SHOW WARNINGS" didn't pop up anything and not surprisingly, php's mysql_error() didn't retu...

Sql results into php array.

Hi, I would like to create an array (in php) from sql results like this: We have the sql-table "Posts" which stores the Name and the Message.Example: Name | Message John | Hello Nick | nice day George | Good bye John | where What i want is to output the names of people who have posted a message but dont display...

Looking to downgrade phpMyAdmin, but don't know what version.

Had to re-set up everything on my laptop recently, which included reinstalling XAMPP. While I was quite happy with the version of phpMyAdmin I had installed the first time around, the new bundled version has a few quirks that get to me. Specifically: Auto-incremented fields ignore values I enter when inserting new rows (e.g. if I wan...

How do I sort the result of an SQL join by a single column in PHP

I have a database with a list of locations e.g.: C_ID | Name 1 | Italy 2 | Germany 3 | France 4 | Spain and in a seperate table, a list of people who are from those countries, P_ID | Name | C_ID 1 | John | 1 2 | Mark | 1 3 | Paul | 2 4 | Pierre | 3 5 | Alan | 2 I have grabbed ...

PHP: Multithreaded PHP / Web Services?

Greetings All! I am having some troubles on how to execute thousands upon thousands of requests to a web service (eBay), I have a limit of 5 million calls per day, so there are no problems on that end. However, I'm trying to figure out how to process 1,000 - 10,000 requests every minute to every 5 minutes. Basically the flow is: 1) Ge...

mysql locking question

Hi. Investigating/researching mysql/myisam locking. trying to find a good example of how to set the lock in appA, and determine/detect the tbl lock in appB. searching google, not seeing much, so i must be missing something. i'm going to be writing a php app that demonstrates this process. pointers/thoughts/thanks.. -tom ...

Database: Best performance way to query geo location data ???

I have a MySQL database. I store homes in the database and perform literally just 1 query against the database, but I need this query to be performed super fast, and that's to return all homes within a square box geo latitude & longitude. SELECT * FROM homes WHERE geolat BETWEEN ??? AND ??? AND geolng BETWEEN ??? AND ??? How is the b...

MySQL world database Trying to avoid subquery

I'm using the MySQL WORLD database. For each Continent, I want to return the Name of the country with the largest population. I was able to come up with a query that works. Trying to find another query that uses join only and avoid the subquery. Is there a way to write this query using JOIN? SELECT Continent, Name FROM Country c1 WH...

Select a row and rows around it

Ok, let's say I have a table with photos. What I want to do is on a page display the photo based on the id in the URI. Bellow the photo I want to have 10 thumbnails of nearby photos and the current photo should be in the middle of the thumbnails. Here's my query so far (this is just an example, I used 7 as id): SELECT A.* FROM (...

Need a hand writing a MySQL query for related videos

So firstly here is the relevant table structure: TUBE_VIDEOS ------ id video_name TAGS ---- id tag_name tag_type [either set to "actor" or "tag"] TUBE_VIDEO_TAGS ---- tube_video_id tag_id I had asked a question a while back about how to use this data to get related videos: here -- this solution basically took videos with the most co...

MySQL Beach Ball from NOT IN query

I have two queries that each return a list of node ids SELECT node.nid FROM dpf_node AS node WHERE node.type = 'image' AND node.nid; SELECT node.nid FROM dpf_node AS node, dpf_image_galleries_images AS image WHERE image.image_nid = node.nid AND node.type = 'image' AND image.gallery_nid = 138; Both of these are work...

MySQL - is it legal to do 'SELECT table1.*,table2.column FROM table1,table2'?

MySQL - is it legal to do 'SELECT table1.*,table2.column FROM table1,table2'? ...

c++ Mysql C API mysql_real_escape_string

I'm building a class wrapper for the mysql c api, specifically at the moment for mysql_real_escape_string and I don't think I'm doing it quite right. this is what I have for the function: std::string Database::EscapeString(const char *pStr) { char *tStr = new char[strlen(pStr)*2+1]; mysql_real_escape_string(m_sqlCon, tStr, pStr...

can't load_file data in the mysql directory

I'm running as mysql root user on my system. I can select load_file('/etc/passwd'); no problem But when I try to select load_file('/var/lib/mysql/mysql'); I get NULL as a result why? this file is good, I can cat it as root and view the mysql user data, why cant mysql load_file it? Its permissions are the default: -rw-rw---- 1 mysql my...

How can I prevent inner SELECT from returning NULL?

How can I prevent inner SELECT from returning NULL (when matches no rows) and force query to fail. INSERT INTO tt (t1_id, t2_id) VALUES ( (SELECT id FROM t1 WHERE ...), (SELECT id FROM t2 WHERE ...) ); Side question: is there better way form this query (t1_id, t2_id are foreign keys, but might be NULL) ? ...