mysql

Mysql create database with new database location

Few months ago I have asked a question regarding how to change database location at runtime - I didn't get any solution for this problem yet. I am needing to create more than 32,000 databases in MySQL. The default data location of MySQL data folder, after creating 32,000 database on that location, I want to change the data directory to ...

Php Syntax Help

I'm working on a search function, it was working fine four days ago, now it's returning this error 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 'AND state = 'AZ '' at line 1 what is the proper syntax for this line? if($search_state !== "") { $qu...

How to insert, if I need to pick up Primary id for other table

SELECT * FROM tableFoo LEFT JOIN tableBar ON tableFoo.commonColumn = tableBar.commonColumn WHERE tableBar.commonColumn IS NULL Above will select records, I would like to insert Code below will insert id to third table. INSERT IGNORE INTO jos_mt_links (link_id,link_name,alias) VALUES(NULL,'tex2','hello'); # generate ID by inser...

Mysql Using JOINs and WHERE statment. What is this difference?

What is the difference bettween SELECT a.AccountId FROM Accounts AS a JOIN domain as d; and SELECT a.AccountId FROM Accounts AS a JOIN domain as d WHERE a.AccountId=d.AccountId; I thought JOIN is an inner join which only matches when the left AccountId is == to the right AccountId. Wouldn't the above be exactly the same? I got diff...

Recording user pageviews, then turning this into useful data?

Hi everyone. My site logs clicks to a database whenever a user views an article. This table is automatically cleared out every 3 days. We use the data to work out the most viewed pages over that 3 day period. I'd also like to use this data for marketing purposes, eg, to determine which users like which sections of the site. I've writt...

mysql: only log a certain db or ignore other db's?

Hi, I'm logging output with log = /var/log/mysql/query.log and this works ok, but I only want to log requests to one database and not the others. How can I do this? Thanks! ...

MSDTC (Distributed Transactions) support in MySQL

Does MySQL support MSDTC? ...

trap event when new wordpress post is added in a certain category

Hi all I need to create a function which is triggered when a new wordpress post is added to the posts table for a particular category. The function will grab the title of the post and add it to a new table called 'newsites' whose fields are (postid, title, questions, users) which is already created. The 'questions' and 'users' fields ...

Ruby convert Mysql timestamp to Mysql datetime

I am trying to import data from a DB to another. The source DB has TIMESTAMP (mysql) the destination has DATETIME (mysql). I am trying something like that: start_at = DateTime.at(row['QA_CONF_START_STAMP']) #start_at But it is not working ...

MySQL Slow Query Analysis and Indexing

Recently, we've noticed a particular query popping up in our slow query logs taking quite some time. I've analyzed it to the best of my ability, but can't figure out for the life of me why it's taking so long, and why the indexes we've set up aren't being used. Here's a simplified (i.e., readable) version of the query for the purpose ...

mysql: export single row, but with all dependencies

Mysql question. I want to export one single row from one table with a catch: I want to pull together with it all the rows in all other tables referenced from the initial row by foreign keys - and referenced from the new rows too, recursively, until I get all rows that the initial one "needs to exist". How can I do that? ...

How should I define different subsets of a common dataset in a web application?

I am speccing out a potential project. The core of the project is a set of data that the client wants to be able to present to different third-parties. The client wants to be able to offer different subsets of the data to different third-parties. The data will be stored in a MySQL database. A web app will connect to the database and pro...

Change spaces to -

I am inserting Alias field for my db called $alias how do I code (I am using php for mysql insert) to remove all spaces and replace space with "-" (trying to change it to "weburl format" ie removing spaces) Thanks ...

Add 30 days for date in db

I have publish up date and publish down date in my DB. Currently they are both same dates. How do I change it (during mysql insert) so publish down date is 30 days past publish up date. I am using $pubDate Thanks ...

BDD with Cucumber and MySQL — auto increment issues

I am writing some Cucumber features for my RoR app that insert records into the database then send a query to my XML API. Because of the nature of my requests (hardcoded XML) I need to know what the ID of a row is going to be. Here is my Scenario: Scenario: Client requests call info Given There is a call like: | id | calle...

SQL Query to Show If Two Users in Same Group

I've got a database with 3 tables: users, groups, and groupmembers. users: id int username varchar(50) groups: id int name varchar(50) groupmembers: id int groupid int user int Given two user ids, how can I use one query to determine if they share membership in any group (not any particular one, but any group). I'd like the query t...

MySql Stored Procedures Parameter Escaping

I came across something odd that I feel is to blatant to be a bug so I am guessing that I am doing something wrong: I have the following Table: CREATE TABLE BlurbTest ( ID SERIAL NOT NULL ,Blurb TEXT NOT NULL ); With the following stored proc: DELIMITER $$ CREATE PROCEDURE spInsertBlurbTest ( OUT ID INT ...

Simple Hello World Zend frameworks for PHP Script Required

According to Phpinfo Zend is installed (Zend Engine v2.1.0) . How ever when I call zend database commands they are swallowed without response or error message. (The script has been tested on my local server). I am looking for a "Zend hello world" php script which will tell me that Zend is running OK. Suggestions? ...

Mysql 2 queries in one?

Apparently i need two queries to get the data i need. I cant give out to much information but is it possible to write 2 queries in one statement? (I have a feeling it is possible). Using mysql 4 ...

Limit second and third sql if no insert

I got on my php script $result1 = mysql_query("insert ignore into...this.... $result2 = mysql_query("insert into...that.... $result3 = mysql_query("insert ignore...again those all are different queries. when first query tries to insert, and if it has duplicate record, it does not enter this. well I dont want to run second and third ...