mysql

PHP hangs waiting for exec to return results from wget+mysql command

Related: see here I've got this command: exec("(wget -O http://domain/file.zip && mysql -u user -ppassword database -e \"UPDATE \\`table\\` SET \\`status\\` = 'live' WHERE \\`id\\` = '1234'\") & echo \$!"); The above command works fine, however PHP waits for the video to finish downloading before going on to the next download. The f...

how do i join 7 tables where a column (which exists in all tables) equals the same content in all tables?

i have seen how to inner join 2 tables where a column is equal to the content in another column. but how do i do this with 7 tables?' thanks everyone, I figured it out lol after a long time. this seems to work SELECT * FROM tbl_school INNER JOIN tbl_apprequirments ON (tbl_school.schoolname = tbl_apprequirments.schoolname) INNER J...

Returning multiple rows per row (in Zend Framework)

I have a MySQL database containing these tables: sessions -------- sessionid (INT) [courseid (INT)] [locationid (INT)] [comment (TEXT)] dates ----- dateid (INT) sessionid (INT) date (DATE) courses ------- ... locations --------- ... Each session has a unique sessionid, and each date has a unique dateid. But dates don't necessarily...

SQL to select the middle third of all values in a column in PostgreSQL

Suppose I have a column of heights -- how can I select all and only those height values that are neither in the top 30% of values nor the bottom 30% of values. UPDATE: I'd like the answer for PostgreSQL (or, failing that, MySQL -- I'm using Rails). ...

How do I insert a large number of rows in MySQL?

How do I insert for example 100 000 rows into MySQL table with a single query? ...

mysql access without webserver (ex. Apache)

I was wondering if there is a way to access a database service on a remote computer without having a webserver installed on that computer? Does MYSQL DBMS provide some interface (port) which can be connected directly to, or is a webserver (that forwards the communication) mandatory? ...

Help needed in java stored procedure with OUT parameter for MYSQL

I want to create a java program for connection with mysql database I want to use stored procedure with 1 out parameter and 1 in parameter How to retrieve result using java Is there any working example? Thanks, Deepak ...

creating two rows at the same time with a foreign key relation

using php and mysql I have two tables, a users table and a profiles table. When a new account is created on my site the user and profile rows are created at the same time. I want a foreign key to reference from the users table to the profiles table so that the users profile information will be stored in a seperate table. My questi...

Perform sum, average, and multiplication across all columns in a table?

I have a table that looks like this: id test1 test2 test3 test4 ... test200 1 90 87 85 86 70 2 100 95 83 92 80 . . 18000 I know there are standard operations to perform sums and averages on a single column and multiply the value of two columns together but is it ...

How can I map a local unix socket to an inet socket?

I'm curious if it is possible to map a UNIX socket on to an INET socket. The situation is simply that I'd like to connect to a MySQL server. Unfortunately it has INET sockets disabled and therefore I can only connect with UNIX sockets. The tools I'm using/writing have to connect on an INET socket, so I'm trying to see if I can map one on...

MySQL: Determine Table's Primary Key Dynamically

I'm, generating a SQL query like this in PHP: $sql = sprintf("UPDATE %s SET %s = %s WHERE %s = %s", ...); Since almost every part of this query is dynamic I need a way to determine the table's primary key dynamically, so that I'd have a query like this: $sql = sprintf("UPDATE %s SET %s=%s WHERE PRIMARY_KEY = %s", ...); Is there a M...

MySQL 5 doesn't recognize BEFORE?

In MySQL 5.0.51b on my Mac, ordinals beyond FIRST fail, as does BEFORE. So, ALTER TABLE my_contacts ADD COLUMN phone VARCHAR(10) FOURTH; fails altogether, as would ALTER TABLE my_contacts ADD COLUMN phone VARCHAR(10) BEFORE email; Do these work with any other flavors or versions of MySQL? ...

Insight on a query optimization

I am trying here to basically find users that do have sports & regions targeted by an activity. In the acces [users] table there is around 17K users. Each can have a certain number of sport interests and one region. There query here look for each users that have one sport & one region at least that are targeted via the activities. Spor...

SQL query works on testing server but not live... what could be the difference?

SOLVED: I wrote and tested a PHP script on the local server. (Nothing fancy, just 2 consecutive SQL inserts in the same database, but different tables). Both servers run PHP5 & MYSQL 5. On the local server, both queries are processed correctly. On the live server, only the first query works, but not the second and I can't figure out ...

Matching rows without filtering (SQL)

I've got table with properties of some products: table properties( prop_id int, product_id int ) My question is: is it possible to select properties that match without filtering them from the result? For example: select property_id from properties WHERE property_id IN(1,3,5); You get only rows that match 1,3,5. I need all rows...

Load-balanced MySQL cluster without load balancer

Hi. I'm looking to create a load-balanced MySQL cluster, but without the actual load-balancer, in order not to add another point of failure or complexity. What I was thinking was to have the following: 1) Have a master-master setup for MySQL 2) On every client, place a simple round-robin proxy which would rotate the requests between ...

Is there any reason to worry about the column order in a table?

I know you can ALTER the column order in MySQL with FIRST and AFTER, but why would you want to bother? Since good queries explicitly name columns when inserting data, is there really any reason to care what order your columns are in in the table? ...

PHP/MySQL: Select locations close to a given location from DB

Hello! In PHP, I have the following code for calculating the distance between two locations: <?php function distance($lat1, $long1, $lat2, $long2) { // DEGREE TO RADIAN $latitude1 = $lat1/180*pi(); $longitude1 = $long1/180*pi(); $latitude2 = $lat2/180*pi(); $longitude2 = $long2/180*pi(); // FORMULA: e = ARCCOS (...

MySQL to get the count of rows that fall on a date for each day of a month

I have a table that contains a list of community events with columns for the days the event starts and ends. If the end date is 0 then the event occurs only on the start day. I have a query that returns the number of events happening on any given day: SELECT COUNT(*) FROM p_community e WHERE (TO_DAYS(e.date_ends)=0 AND DATE(e.dat...

SQL Many-to-Many Query Problem

I have three tables: videos, videos_categories, and categories. The tables look like this: videos: video_id, title, etc... videos_categories: video_id, category_id categories: category_id, name, etc... In my app, I allow a user to multiselect categories. When they do so, I need to return all videos that are in every selected categor...