mysql

MySQL - Query All users WITHOUT an appointment

If I have two tables: Users and Appointments. How would I query the db to find something like the following: SELECT * FROM users WHERE (none of: appointments.user = user.id) I am assuming I would need some type of join with the appointments table, just not sure where to start. ...

SELECT statement for the "length" of the field is greater than 1

I have an LINK field in my table. Some rows have a link, some don't. I'd like to select all rows where LINK is present. (length is greater than X characters). How to write this? ...

Which tables will be locked with this query?

I am migrating data between two tables using the query below. I had table locking issues, so I am considering changing the table engines from MyISAM to InnoDB. Which tables do I need to do that for? Just the table I am writing to, or both the table I am writing to and the one I am reading from? INSERT INTO table1 ( field1, field2, fie...

reverse engineer mysql database to create django app

I basically want to take an existing mysql database structure created and used by a php app (codeigniter framework) and reverse engineer it to a django app. is there some tool to do this? south migrations maybe? ...

MySQL performance using IN predicate

If I run the following queries each one returns quickly (0.01 sec) and gives me my desired result. SELECT tagId FROM tag WHERE name='programming' SELECT COUNT(DISTINCT workcode) FROM worktag WHERE tagId=123 OR tagId=124 (assume the two tagId numbers were the results from the first query) I would like to combine these queries so I onl...

What is a good beginner's guide for MYSQL Partitioning?

Including...how to set up the partition, how to determine which partition to talk to...etc. I know replication but am new to partitioning. ...

How to query for err in MySQL?

I added a column to my table that does not allow null. I guess that is why some of my rows now have real values in the column but some other rows now have (err) in the column. How can I query for this? select * from Table where new_column = err That doesn't work. ...

Database "pointers" to rows?

Is there a way to have "pointers to rows" in a database? for example I have X product rows, all these rows represent distinct products but many have the same field values except their "id" and "color_id" are different. I thought of just duplicating the rows but this could be error prone, plus making a small change would have to be done...

How To Store Hmong Characters In MySQL Database

I've read a number of articles on storing multi-language strings in MySQL, but I can't seem to find anything specific (or credible) on Hmong. I have no trouble with latin (European) languages, but if someone could enlighten me on Hmong, that would be terrific. Thanks! P.S. Using PHP for the scripting, if anyone cares. ...

MySQL DELIMITER and DECLARE use?

I am trying to port some code from MS-SQL to MySQL and there is this code that declares a variable and then executes some select statements - it looks like: USE MarketDB; GO DECLARE @Q0 VARCHAR(16); DECLARE @Q1 VARCHAR(16); SET @Q0 = '05/30/2008' SET @Q1 = '08/29/2008' Now I try to convert this to MySQL and fail totally. Why does the...

How can I optimize this query?

I've got a bit of a nasty query with several subselects that are really slowing it down. I'm already caching the query, but the results of it changes often and the query results are meant to be shown on a high traffic page. SELECT user_id, user_id AS uid, (SELECT correct_words FROM score ...

MySQL SELECT INTO Equivalent?

In SQL Server, I can copy tables or temporary tables to new table, using a SELECT* INTO.. syntax. Someone know how can I make this same action in MySQL? ...

How to perform search on MySQL table for a website.

How do I perform a search similar to that of Wikipedia on a MySQL table (or several tables at a time) without crawling the database first? (Search on wikipedia used to show you the relevancy in percentage). What I'm looking for here is how to determine relevancy of the results and sort them accordingly, especially in case where you pull...

How to deal with .1 & .10 with MySQL & Rails

I currently have a MySQL database with a table that has a field that is typed as a decimal. Currently there are values that range from *.1 through *.9 but we now need to be able to handle the following: I need to be able to add *.10 to this field and sort it accordingly. In this use-case .10 DOES NOT equal .1! I need to be able to us...

mySQL/PHP to update if the row exists or else insert when column to check is not unique

I have read about REPLACE and INSERT ON DUPLICATE key queries, and while I can see how useful they are, they don't appear to work for my purposes. Perhaps my database design is off from how it should be, but either way I hope I can get this working. I am trying to mock up an online store to teach myself mysql and php, and I am recording...

Entering Dates into mysql database using sql INSERT

A better suggestion on how to approach this then what I have done so far would be appreciated. Right now the dates have to be entered in the correct format year-month-day. Is there a way to automate this task more, with drop downs, just not sure how you would combine the information from the drop downs to submit to one field with my sql ...

SQL - How to find the highest number in a column?

Lets say I have the following data in the Customers table: (nothing more) ID FirstName LastName ------------------------------- 20 John Mackenzie 21 Ted Green 22 Marcy Nate What sort of SELECT statement can get me the number 22, in the ID column? I need to do something like this to generate a unique ID....

Trees in Symfony

Does someone know a stable tree adminstration plugin (nested set etc.) for the symfony framework, which is able to operate on separated database tables? ...

MySql: "SHOW CREATE TABLE" doesn't work for tables named "x-..."?

Hi! The SWOW CREATE TABLE query doesn't seem to give any result if the table has no rows. (At least not in my php setup.) Is there an easy way to get around that without delving into the meta tables? If so, how? :-) EDIT: As my comment on Quassnoi's answer below indicates, this seems to be a problem for tables named starting "x-"... ...

How to change name of table while creating it through Stored procedure...

I want to write a Stored procedure...which will create a table with xyz name ...but when i call the SP for very second time it will give the error bcoz table already exist...I want to take table name as input..and want table to be created with that name... How to archive this..... Asp.net ---My sql ...