mysql

Is it Possible to Use Constraints on Hierarchical Data in a Self-Referential Table?

Suppose you have the following table, intended to represent hierarchical data: +--------+-------------+ | Field | Type | +--------+-------------+ | id | int(10) | | parent | int(10) | | name | varchar(45) | +--------+-------------+ The table is self-referential in that the parent_id refers to id. So you might ha...

PHP Apostrophe and query string.

I want to supply a SQL statement from the query string, but all my efforts result in escaped single quotes and slashes. ...

how to insert date in MySQL

i am developing window application using visual studio and c# i want to insert date in Mysql database table which having datatype date using datetimepicker control of visual studio i wrote insertquery like this (insert into table name values('"+ datetimepicker.value + "') it give me following error ERROR [HY000] [MySQL][ODBC 3.51 Dri...

I am trying to SELECT WHERE IN SELECT, what I am I doing wrong?

SELECT * FROM `seriallog` WHERE `lastevent` IN (SELECT GROUP_CONCAT(CONCAT(' \'', `eventid`, '\'')) FROM `permissions` WHERE `permissions`.`userpkid` = 1) ...

limit in subquery mysql

I am tying an alternate to limit sub queries in mysql, since mysql 5 does not support limit keyword in subquery: SET @i = 0; SELECT BuildID, COUNT(TestCase) from results R where R.BuildID IN (select B.BuildID from build B where ( @i := ( @i +1 ) ) <= 25 and B....

Some websites to learn about MySQL tables and creating databases (The Do's and Don'ts)

I am venturing on making a website with a database for baseball games for an intramural league. I have made databases before, but this project seems to have many fields that will require at least 3 tables. I want to make the tables correct, so that I can sort and gather information from multiple fields properly ( such as the team table ...

MySql UDF using shared library won't load

I am attempting to create a mysql UDF which will match a fingerprint using Digital Persona's free linux SDK library. I have written a trivial UDF as a learning experience which worked fine. However, when I added a dependency to Digital Persona's shared object I can no longer get MySql to load my UDF. I added includes to DP's headers a...

Sending variables in URLs in PHP with echo

Hi all, I can't really find good guidelines through google searches of the proper way to escape variables in URLs. Basically I am printing out a bunch of results from a mysql query in a table and I want one of the entries in each row to be a link to that result's page. I think this is easy, that I'm just missing a apostrophe or backslas...

Storing affiliate leads and conversions

I've created an affilaite system that tracks leads and conversions. The leads and conversions records will go into the millions so I need a good way to store them. Users will need to track the stats hourly, daily, weekly and monthly. Whats the best way to store the leads and conversions? ...

Getting "Error loading MySQLdb module: No module named MySQLdb" - have tried previously posted solutions

This is a much discussed issue for OSX 10.6 users, but I haven't been able to find a solution that works. Here's my setup: Python 2.6.1 64bit Django 1.2.1 MySQL 5.1.47 osx10.6 64bit I create a virtualenvwrapper with --no-site-packages, then installed Django. When I activate the virtualenv and run python manage.py syncdb, I get this err...

Inserting more than one record with a single insert statement

How can MySQL insert multiple records by executing a single insert statement? The problem at hand involves 1 to 10 records, depending upon user input. ...

special characters strange behavior

Hi, i have this string in my utf-8 mysql DB: "Pruebá de eñes" When i print it like plain text, everything works ok, but if i load that same field inside an input, textarea, etc, it becomes: "Pruebá de eñes" How can i solve this problem? =( ...

MySQL MATCH AGAINST functionality....

Currently I have the following query... SELECT id, LOWER(title) as title, LOWER(sub_title) as sub_title FROM ebay_archive_listing WHERE MATCH(title, sub_title) AGAINST ("key" IN BOOLEAN MODE) However it is not finding rows where the title contains the word "key". "key" is generated dynamically based on a set of ke...

Integer Surrogate Key?

I need something real simple, that for some reason I am unable to accomplish up to this point. I have also been unable to Google the answer surprisingly. I need to number the entries in different tables uniquely. I am aware of AUTO INCREMENT in MySQL and that it will be involved. My situation would be as follows: If I had a table like ...

Perl Script to search and replace in .SQL query file with user inputs

I have a .SQL file containing a large number of queries. They are being run against a database containing data for multiple states over multiple years. The machine I am running this on can only handle running the queries for one state, in one year, at a time. I am trying to create a Perl script that takes user input for the state abbrev...

How can I create a small relational database in MySQL?

I need to make a small database in MySQL that has two tables. Clothes and ClotheType Clothes has: ID, Name, Color, Brand, Price, ClotheTypeID ClotheType has: ID, Description In Microsoft SQL it would be: create table Clothes( id int, primary key(id), name varchar(200), color varchar(200), brand varchar(200), price varchar(200), cloth...

php date() vs mysql MONTH()

Hi, i have this unix timestamp value: 1275364800 (1st june 2010). When printing that value with php: echo date('m',1275364800) it returns 6 (thats ok) But when i select a field from a database: select MONTH(FROM_UNIXTIME(1275364800)) AS month it returns 5 Why? BTW, if i run this query select FROM_UNIXTIME(1275364800) AS q i get 2010-...

Getting the last entry of a user from a MySQL table ordered by DateTime

Hello, I have a table who looks something like this: USERNAME DATA DATETIME Jhon text1 2010-06-01 16:29:43 Mike text2 2010-06-01 16:29:22 Silver text3 2010-05-23 06:19:12 Jhon text1 2010-02-01 01:02:00 What is the php command if i want the DATA from the LAST entry made by Jhon ??? Thanks! ...

Query to sum duplicated fields

Here is mysql data id usr good quant delayed cart_ts ------------------------------------------------------ 14 4 1 1 0 20100601235348 13 4 11 1 0 20100601235345 12 4 4 1 0 20100601235335 11 4 1 1 0 20100601235051 10 4 11 1 0 20100601235051 9 4 4 1 0 20100601235051 15 4 2 1...

Weird MySQL behavior, seems like a SQL bug

I'm getting a very strange behavior in MySQL, which looks like some kind of weird bug. I know it's common to blame the tried and tested tool for one's mistakes, but I've been going around this for a while. I have 2 tables, I, with 2797 records, and C, with 1429. C references I. I want to delete all records in I that are not used by C, s...