mysql

PHP preg_match: a pattern which satisfies all MySQL field names (including 'table.field' formations)

i need a pattern which satisfies mysql field names, but also with the option of having a table name before it examples: mytable.myfield myfield my4732894__7289FiEld here's what i tried: $pattern = "/^[a-zA-Z0-9_]*?[\.[a-zA-Z0-9_]]?$/"; this worked for what i needed before, which was just the field name: $pattern = "/^[a-zA-Z0-9_]...

Help needed with MySQL query to join data spanning multiple tables with data used as column names

I need a little help putting together a SQL query that will give me the following resultsets: and The data model looks like this: The tricky part for me is that the columns to the right of the "Product" in the resultset aren't really columns in the database but rather key/value pairs spanned across the data model. Table data i...

Why is Zend Framework (Zend_Db_table) rejecting this SQL Query?

I'm working on a simple JOIN of two tables (urls and companies). I am using this query call: print $this->_db->select()->from(array('u' => 'urls'), array('id', 'url', 'company_id')) ->join(array('c' => 'companies'), 'u.company_id = c.id'); whic...

MySQL delete row after 'expiry'

Hi, I am trying to delete expired entries in a MySQL database, on creation or update a field called lastBeat is updated with CURRENT_TIME and I use the following query to check/delete rows older than 20 seconds: DELETE * FROM rmachines WHERE lastBeat < (NOW() - 20); I have also tried CURRENT_TIME instead of NOW() There are 2 ma...

Problem with multi-table MySQL query

I have 3 tables. Here is the relevant information needed for each. items prod_id order_id item_qty primarykey is prod_id orders order_id order_date order_status acct_id primary-key is order_id key is acct_id accounts acct_id is_wholesale primary-key is acct_id items is linked to order by the order_id and orders is linked to acco...

PHP Session Management, Counting Users With Cookie

I want to, upon loading the page, store a cookie in the user's browser. Then, using AJAX, count the number of users with that cookie and send it off to a database row every 1 second or so. How is this accomplished? ...

MySQL Insert not working with Date column

Hello All, I am having an issue with a simple insert query into a table. I have this PHP Code $T_MEMBER = "INSERT INTO T_MEMBER (MEMBER_IDENTIFIER,LAST_NAME,FIRST_NAME,BIRTH_DATE) VALUES ('$memberID','$last','$first','$birthdate')"; mysql_query($T_MEMBER) or die(mysql_error()); Here are a few examples of what the query looks like...

Archive Parent / Child Table Hierarchy in MySQL

If I have a Parent and Child table in MySQL related by a foreign key, is it possible using a SQL statement to move certain rows from Parent and the related rows from Child into archive tables (e.g. Parent_Archive and Child_Archive) in an atomic manner? ...

Reset ID autoincrement ? phpmyadmin

Hi, I was testing some data in my tables of my database, to see if there was any error, now I cleaned all the testing data, but my id (auto increment) does not start from 1 anymore, can (how do) I reset it ? Sorry for any mistake in English, and thanks for the attention. ...

Advice on how to complete specific MySQL JOIN

Hello, I have a mysql table jobs. This is the basic structure of jobs. id booked_user_id assigned_user_id I then also have another table, meta. Meta has the structure: id user_id first_name last_name Here is my php code $sQuery = " SELECT SQL_CALC_FOUND_ROWS job_id, job_name, priority_id, meta.first_name, date_booked ...

Is there any open source tool/software which can test data between two different databases ?

Hi, I want an open source/free tool which can test the schema, data, user defined functions, views and stored procedures between two different databases or two different versions of the databases. I am using MySQL database. Currently I am using DB Solo which is a 30 day trail version. Thanks in advance. ...

random record from mysql table

Is there any built-in function except order by random() to select a random record in mysql table? ...

MySQL select: maximum 3 photos from the same album

Hello there! I have table with next structure: `id` (int), `album_id` (int), `photo_id` (int), `date_added` (int) The task is next: I must select 100 photos from this table, ordered by date_added and intricacy in that I could select maximum 3 picture from the same album. That is I could select one, two or three photos from one album ...

mysql_connect() doesn't work when run by apache; works from command line.

Hi, I have a strange issue. I'm trying to write a simple php webpage on my server, but mysql_connect() doesn't connect to any server, either local or otherwise. Here's where it gets strange. If I take the same php script and run it from the commandline, the script works. phpinfo() indicates that both the file (being run by apache) and th...

Rails 3.o MYSQL connection problem

Hi I have installed RVM in my ubunut linux box and configured the Rails 3 app in that ... i can able to start app server... my problem is when i invoke http://localhost:3000 . i getting the follwing error Mysql::Error (Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)): I checked mysqld service...

BackUp MySql Database from CommandLine

I am able to backup mysql database via command line by executing the below : C:\MySQL\MySQL Server 5.0\bin\mysqldump\" -uroot -ppassword sample > \"D:/admindb/AAR12.sql\" But there is no DROP and CREATE database queries in my .mysql file What should i add in the syntax to get the create info to my generated .sql file ? -- M...

Can JavaScript connect with MySQL?

Can JavaScript connect with MySQL? If so, how? ...

retreaving timestamp record from databse

how to access timestamp object in resultset. i use this code String displayzone =Rs.getTimestamp("TIME_ZONE").toString(); it will be error.... ...

How to execute the .sql file of Mysql via command prompt

I have a .sql file generated by MysqlDump. How can i restore it via command prompt ...

differentiating results of sql right join

Hi I have a below SQL query SELECT `User`.`username` , Permalink.perma_link_id, Permalink.locale, Permalink.title, DATEDIFF( CURDATE( ) , Permalink.created ) AS dtdiff, `TargetSegment`.segment_text, TargetSegment.source_segment_id, TargetSegment.perma_link_id ,TargetSegment.created , TargetSegment.updated, DATEDIFF...