mysql

what is difference between 'where' and different 'joins' in mysql ??

Possible Duplicate: In MySQL queries, why use join instead of where? Joins are always confusing for me..can anyone tell me what is difference between different joins and which one is quickest and when to use which join and what is difference between join and where clause ?? Plz give ur answer in detail as i already read about ...

recursive self query

I have the following table: myTable: +----+----------+ | id | parentID | +----+----------+ | 1 | null | | 2 | 1 | | 3 | 1 | | 4 | 2 | | 5 | 4 | ----------------- i would like to get all rows tracing back until there's no parentID anymore. So ".... WHERE id=5" would give me: 5, 4, 2, 1 ...

How to export multilingual MySQL table to Excel without garbled text (e.g. à¹à¸­à¸™à¸™à)?

I have a MySQL table where I store text entered in any kind of language. The text is displayed correctly on the website, example but when I export the data to Excel I get garbled text. I tried exporting the data via PHPMyAdmin and even just doing something from the command line like mysql -user -p db < query.sql > export.tsv and I get...

MySQL foreign key question

Does defining a foreign key also defines a index? I have mysql v5.1.46 & I am looking at the MySQL Administrator tool and its shows the foreign key as an index, so I wanted to confirm? ...

MySQL: conduct a fuzzy search

I have a names table in my database and I would wish to conduct a fuzzy search on it for example my database contains: Name ID John Smith 1 Edward Smith 2 Gabriel Gray 3 Paul Roberts 4 At the moment when I search the database via python I can only do exact match searching. But I would like to be able to do fuzzy searching w...

mysql syntax error inserting decimal, timestamp with php

Im getting the 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 '10', '16:39:02', '292.35')' at line 1 this is the query im running in php: mysql_query("INSERT INTO `copper` (`month`, `time`, `price`) VALUES ...

Very simple query on mySQL (beginner question)

Hi ! I have a very simple question for a beginner in SQL. I have defined 3 tables in my database : "DOCTOR", "PATIENTS", "VISITS". For simplicity purposes, I have only a one-to-many relationship btw these tables : One doctor has many patients, but a patient can see only one doctor and one patient can make many visits... in my table "VISI...

Image uploading with PHP

I've been building an event promotion site in PHP and MySQL for the past couple of months where anyone can sign up and add their local event's details along with a poster, which I resize. As it stands, I've got the whole process working fine locally and on a hosting service, but before the site goes live I have a couple of questions on...

Updating serialised array in mysql (without unserialising?)

Everything I've read says that storing serialised arrays in Mysql is a bad idea - I know that already ;) Unfortunately I'm working with an open source script that uses this method, and changing the structure isn't an option in this scenario. Is it possible to update this URL without first unserialising? I originally tried using replace...

My SQL requires a user has logged in successfully once before, how can I modify to remove that requirement?

Here is my SQL 'SELECT u.`id`, u.`email`, u.`password`, u.`first_name`, u.`last_name`, u.`role_id`, MAX( ul.`datetime` ) as `last_login`, SUM( ul.`failed` ) as `failed_logins` FROM `users` `u` JOIN ( SELECT `user_...

Very Fast PHP-MySQL interaction

Hi!, i'm lookin for a way to make some kind of function into php and mysql who give me as a result the id of a record in a simple table. I got a id -> value table where the id is an autoincrement field. The natural way or the simple way i know is: $myId = Check('Cheese'); function Check($value) { $sql = "SELECT id FROM table...

Listing data from mysql tables

Hi. I have 3 tables: recipe_category cid | category 1 | desserts 2 | cakes 3 | biscuits recipe_name id | recipe_name | cid | iid 1 | black forest cake | 1,2 | 1,2,3,4 2 | angel cake | 2 | 1,2,4 3 | melting moments | 3 | 2,5 4 | croquembouche | 1,3 | 1,5 ingredients iid | ingredient_name 1 | self...

What mysql driver do I use with spring/hibernate?

Little confused, is 'driverclassname' and 'hibernate.dialect' both referring to the mysql driver? What should I be using? Is the connectorJ the one I should use? <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> ...

MySQL - Capitalize first letter of each word, in existing table

Hi all. I have an existing table 'people_table', with a field 'full_name'. Many records have the 'full_name' field populated with incorrect casing. e.g. 'fred Jones' or 'fred jones' or 'Fred jones'. I can find these errant entries with: SELECT * FROM people_table WHERE full_name REGEXP BINARY '^[a-z]'; Q. How can I capitalize the...

phpmyadmin error "#1062 - Duplicate entry '1' for key 1"

I dropped all tables from a database then restore(import) a backup. and getting this error. Should i repeat the process. or something else? Why this error is coming? ...

IIS - Mysql Performance Issue

Hi, I have developed a site on linux server(my testing host server). But When I move the site to live server, which is IIS, Windows 2003... my site is very slow. It takes around 20 seconds to load a page. My code is in PHP and I am using Wordpress. Normal Html, Php pages are running fast, but when it connects to MySql.. it takes 4 to 5...

Date Validation in MySQL

Can anyone help me on how did MySQL can't read a rows of I've try to execute this query. SELECT * FROM attendance where '2010-07-13 00:06:00' BETWEEN timein AND timeout; This is the date in the table: +-----------------------+-----------------------+ | timein | timeout | ------------------------+---------...

Setting the starting value of an AUTO_INCREMENT field in MySQL

I have a simple question in creating table in database. Here's my code: $query="CREATE TABLE users ( userid int(5) not null AUTO_INCREMENT, firstname varchar(20), lastname varchar(20), username varchar(30), password varchar(32), email varchar(50), age int(2), PRIMARY KEY (userid) )"; I want the USERID ...

strip all spaces from column in mysql?

hi there, i have a table that has 'number' 1234 12 34 1 2 34 1 2 3 4 ect... so, im wondering how can i write a query that will remove all spaces? something like update `table` set number = REPLACE( ' ', '', (select 'number' from `table`)); is there anything that will do this? ...

Direct database connection vs Web Service, for MySQL+SQL eCommerce integration?

Hi, I need to integrate orders from an online eCommerce site (Linux/PHP) into a client-server system (.Net/MSSQL), as well as checking stock levels and products from the client-server side into the eCommerce site. I found these answers, but they don't satisfy me. The MySQL database is not exposed publicly, while the MSSQL database is. ...