mysql

Recommended tools for a beginner PHP programmer on Windows?

I'm going to teach PHP (plus HTML, plus MySQL) to a complete beginner. What tools do you recommend for Windows in term of editor, web server and general set up? ...

MySQL monitoring tools

I'm going to be releasing a site soon that is on it's own dedicated server and can find plenty of tools for monitoring the server its self (disk usage, cpu usage, memory usage, etc) but can't really find anything for MySQL and was wondering what other people use or recommend. I'm not necessarily looking for something with pretty charts a...

Composite primary key question in MySQL

I am a newbie to databases. I am using MySQL, and I have a table A using three attributes to form a composite primary key: A: [key1, key2, key3], dateCreated, createdBy, ... Now I have another table B, which needs to refer to records from the table above. Now, reusing all the three attributes above again to form a key seems to be a pai...

how to know if last operation was insert or update when using insert on duplicate update in mysql and php?

I am using PHP and MySQL. If I use an INSERT ON DUPLICATE UPDATE SQL statement, then how do I know if the last operation was an successful insert and not an update or unsuccessful insert? The assumptions are the table in question does not use an auto increment, so I can't use a mysql_insert_id to help me find out. ...

Is an UPDATE still executed if a BEFORE trigger creates an error?

If no, is there any way to cancel the UPDATE from out of the trigger? ...

DELETE from mysql table WHERE column equals value AND column2 equals value2

Having some trouble getting this query to work correctly. mysql_query("DELETE FROM `table` WHERE `id` = '$id' AND 'username' = '$username' "); tried replacing variables with actual data and running it in phpmyadmin to no success any thoughts? ...

Replace Part of String in MySQL

If i have data in my MySQL like this table: data(TEXT) foo (hal) foo (dave) bar (dave) bar(dave) And i want to do This Query SELECT DISTINCT(data) FROM table; Now this will return the table as listed above. But i want to do is some sort of replace so that my return query should look like this SELECT D...

Is there any way to tell user how many rows are in a table?

Let's say I have a table full of names and I want users to know how many names are there. What would be the output process be? ...

SQL (for mysql) getting good results, but need to exclude some columns

I'm trying to write a custom search that will search "all categories" and individual categories (via a form/select dropdown). I'm having problems with my individual category search. When I test my sql, it returns good results, but I'm getting extra/unwanted categories in my results. I'm getting those extra categories in my results due...

complex sql order by

id | message | reply id | date 1 | my new app.. | 0 | 10 / 10 / 2009 (latest message on top, follow by replies) 5 | love ur app.. | 1 | 11 / 10 / 2009 (this should show under the main message) 6 | another comm | 1 | 12 / 10 / 2009 2 | application 2 | 0 ...

How can I calculate the top % daily price changes using MySQL?

I have a table called prices which includes the closing price of stocks that I am tracking daily. Here is the schema: CREATE TABLE `prices` ( `id` int(21) NOT NULL auto_increment, `ticker` varchar(21) NOT NULL, `price` decimal(7,2) NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `tick...

Registering org.gjt.mm.mysql.Driver

When I connect to mysql in my localhost, everything is OK. but when i move the whole project to another computer in the intranet and set the correct IP. the project can't connect to mysql, and stop at: Registering org.gjt.mm.mysql.Driver2009-08-09 14:29:41,679 What's Up ? Thanks in advance ! ...

show message when no rows selected mysql php

My code looks like this: $result = mysql_query("SELECT * FROM `picdb` WHERE `picid` = '$picid' ") or trigger_error(mysql_error()); while($row = mysql_fetch_array($result)){ foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } Problem is that when there is no row to select, nothing happens, my $row array is empty. ...

mysql query help?

I have a table with 'id' as the primary field and set to auto increment.. 'name' of type varchar .. 'category' of type varchar .. Table contents ::. * id=1,name=abc,category=tv * id=2,name=abc,category=radio * id=3,name=abc,category=tv * id=4,name=abc,category=radio * id=5,name=abc,category=tv * id=6,name=abc,category=tv Now, I want to...

Need a good jQuery/AJAX tutorial (form upload related)

I've recently started using jQuery with php. On the application I'm currently making I have a form which inserts various text data along with an image file upload. What I want is a good jQuery/AJAX tutorial on submitting this form, having it upload the file (maybe with some kind of loading image/message) then after its finished doing it...

INSERT INTO..SELECT..ON DUPLICATE KEYS ambiguous ids

Hey there, I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id | promoter | generation | turnover | payed | +----+----------+------------+----------+-------+ | 1 | 4 | 1 | 10 | 0 | | 3 | 4 | 5 | 100 | ...

like query doesn't work exact

hey guys, I'm building a little search application (I know I can use match against). But now is the problem: If I'm search after a piece of a word, I'm finding the match, but if I do an exact match, it doesn't work... My mysql code: SELECT * FROM Dames WHERE naam LIKE "%alessia%" LIMIT 0,28 $link->Stuk(1) is just a parameter and ...

MySQL query based on 3 tables

Hello. I work with PHP. I have a table named books. In table books I have the book_name with the name of the book, book_publisher with the publisher's ID and book_author with the author's ID. Besides the books table I have the books_author table with the authors names and IDs and books_publisher with the books publishers names and IDs. ...

Correct normalization of database with optional columns

I need to create a database table that stores parametric descriptions of physiological characteristics (e.g. systolic blood pressure, triglyceride concentrations, etc.) of a hypothetical cohort of patients. For example, supposing the user specifies a triangular distribution for SBP, then the minimum, maximum and mode (and distribution t...

mysql: multiple join problem

Hi, Im trying to select a table with multiple joins, one for the number of comments using COUNT and one to select the total vote value using SUM, the problem is that the two joins affect each other, instead of showing: 3 votes 2 comments I get 3 * 2 = 6 votes and 2 * 3 comments This is the query I'm using: SELECT t.*, COUNT(c.id) as ...