mysql

why index not used here in MYSQL?

Very odd as follows: mysql> explain select *from online where last < now()-interval 30 second and type=1; +----+-------------+--------+------+---------------------------------------+------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Ex...

MySQL Multiple COUNT group

I have this query but I don't know if it's possible to do this. Basically, I'm doing a count and group by each column. However, I want to show the count DESC/ASC. Since they're different columns, I can I achieve this? Here is my query: SELECT flags.ID, flags.COMMENT_ID, flags.CONTENT_ID, flags.USER_ID, flags.WALLPOST_ID, flags.FLAGGED_B...

Is it possible to log down error statements in MYSQL?

So that I can just check the logs to see which statements are wrong at a unified location. ...

speed up operation on mysql

I'm currently writing java project against mysql in a cluster with ten nodes. The program simply pull some information from the database and do some calculation, then push some data back to the database. However, there are millions of rows in the table. Is there any way to split up the job and utilize the cluster architecture? How to do ...

Is it possible to execute a string in MySQL?

I have to convert an MSSQL stored proc that passes a varchar that is a query. The proc has the following command: INSERT INTO Results EXEC (@Expresion); This isn't working. I'm pretty sure that EXEC and EXECUTE arent MySQL commands but CALL doesn't work either. Does anyone know if its even possible to have something like JavaScript'...

How to forward demo data dates using a stored procedure?

Hi guys, I am looking for a clean way to forward some demo data using a stored procedure. The data that I want to forward are date types. Due to the nature of my app, some of the data in my app will only appear when certain dates in the data are in the future. I hope this makes sense. : S Since my database is ever expanding, I was thin...

1 index for 2 kinds of queries below possible in MYSQL?

select xx from tablexx where type in (1,3) and last<current-interval 30 second; select xx from tablexx where type=1; If create index on (type,last),the first one won't use index. If create index on (last,type),the second one won't use index. As for data type,which is can be seen from the example,type: int unsigned,last: datetime ...

mysql float type

hello i am having a database order with price and deposit fields set to float type. iam also implemeting a java gui to search the order , the problem is when i try to search for the orders in the database i dont find anything because it saves price=55.0 when i convert from string to float and in the database it saves as 55 . what is the ...

What is the equivalent of "FOR XML AUTO" in MySQL? (for having an XML string that represents a row)

Hello! In SQL Server I frequently use "FOR XML AUTO", which allows something like "SELECT id FROM car FOR XML AUTO" to return "<car><id>1</id></car><car><id>2</id></car>". Is there a way to do this in MySQL? What I want is to be able to store this XML in another table so I can have complete log of changes made in the database. The hist...

PHP - list() query not working

Hello, When I run the code below when $entry = miami.com, I get the following error message: SELECT COUNT(*) FROM # check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 It looks like I'm not correctly defining $table. Any ideas how I could do that? Thanks in advance, John ...

When to switch from SQLite to MySQL in production?

I am developing a web application in Django. My application is already up, and some users are are using it (say about 5-10). The database is SQLite. Should I move to MySQL now? Or, wait till the user base increases? I don't have any user registration feature, yet. The basic usage of app is - problems are served n users solve them. ...

user-friendly time entry

In my project (based on php/mysql/jquery ) i need the user to enter time. But it seems very annoying to enter the time in strict formats like 06:00 PM or 14:00 So i want to give the user freedom to enter time in a very friendly way like 6 pm, 11am etc or 14 which will then be converted internally into a strict time format for further ...

Updating A Table Based On The Count() From Its Many-to-Many Table

I have a table of groups, of people, and a many-to-many table of group_id,person_id pairs. groups has a count column which should store the current number of people in each group. I'd like to update this information in one SQL command if I can, but I'm not sure how. I imagine some kind of subquery would let me accomplish this, but I'm...

Adding a new column in the Table doesnt cause the result in Cakephp

Hi, I have added a new column to my table Attributes which already has (id , form_id(foreign key),type,label,size,sequence no,instr) where instr is the new column i have added. My application is in Cakephp and Mysql. I have used the following code to insert into the table Attributes But the field instr alone not inserted . ...

Why is this MySQL query not working?

What's wrong with these two queries? SELECT (DATE_ADD('2008-11-31',INTERVAL 365 DAY) + INTERVAL 0 DAY) as occursOn Result: ( [0] => Array ( [occursOn] => ) ) And: SELECT (DATE_ADD('2008-11-31',INTERVAL 730 DAY) + INTERVAL 0 DAY) as occursOn Result: ( [0] => Array ( [occursOn] ...

Help me out with this MySql cursor code

Trying to migrate from MSSQL to MySQL. This Stored Proc is creating a temp table for some columns from a permanent table then using a cursor to update each record's RandNum column with a random number and selects the dataset. As I'm writing this I thought that I could bypass the cursor and just... SELECT Id, Title, DateStart, Rand() FRO...

Is it possible to load a database in the RAM?

I want to load a MYSQL-database into the RAM of my computer, is there a way to do this? I am running this database under Linux. Also, if this is possible, is there a good way to make backups, because if the computer is unexpectedly shut down, I would lose all my data. ...

Updating email addresses in MySQL (regexp?)

Hi, Is there a way to update every email address in MySQL with regexp? What I want to do is to change [email protected] addresses to [email protected]. Is it possible to do with SQL or should I do it with PHP for example? Thanks! ...

MySQL ODBC 3.51 Driver UTF-8 encoding

Currently I am migrating MSSQL to MYSQL.I am using the MySQL ODBC 3.51 driver to connect to mysql using odbc connectivity.I have telugu language charectors stored in the table.They are not showing properly while using the mysql odbc driver, but they are showing up properly while using the sqlserver odbc driver. Here is my connetion stri...

MySQL SELECT x FROM a WHERE NOT IN ( SELECT x FROM b ) - Unexpected result

I expect the result of the third query below to contain id=732. It doesn't. Why is that? mysql> SELECT id FROM match ORDER BY id DESC LIMIT 5 ; +------------+ | id | +------------+ | 732 | | 730 | | 655 | | 458 | | 456 | +------------+ 5 rows in set (0.00 sec) mysql> SELECT id FROM email...