mysql

how to implement a search from search box?

I've got a requirement where a user enters a few terms into a search box and clicks "go". Does anyone have any good resources on how to implement a dynamic search that spans a few database tables? I am using jsp,servelt,jpa as front end and mysql at back end of my project. Thanks, Satya ...

How to turn this MySQL SELECT query into a DELETE query?

I want to delete certain items from the database. I have the following query: SELECT * FROM sheets, entries WHERE entries.sheetID = sheets.id AND sheets.clientID = 13 This works, and returns 2 results. Now I want to turn this SELECT query into a DELETE query. However, the following doesn't work: DELETE FROM sheets, entries WHERE ...

How do I alter a mysql table column defaults?

I have a table with a column of type timestamp which defaults current_timestamp and updates to current_timestamp on every update. I want to remove the "on update" feature on this column. How do I write the alter statement? I tried the following: ALTER TABLE mytable alter column time set DEFAULT now(); but this didn't work. than...

How to connect to MySQL Database from eMbedded Visual C++

How can I connect to a remote Mysql database, from Cpp code using Microsoft eMbedded Visual C++ (which is configured for a special board running WindowsCE)? I have downloaded the source files for Mysql C and C++ Connector/APIs but; their 'make' or installation process is pretty complicated and valid only for Visual Studio. ...

Convert MySQL script to MSSQL

Hello, I have a large MySQL set of commands in a file (script) and I need to execute it on a Microsoft SQL Server 2008. I know there are few differences in both languages, despite the fact the base SQL is the same. Is there any way how to convert a MySQL script to one that is executable on MSSQL server? Or is there any migration app th...

Inconsistent MySQL DATEDIFF behavior

When I use this query: SELECT COUNT(*) FROM `my_table` WHERE DATEDIFF(NOW(), updated) > 2 MySQL executes the query with no errors and I get the count of rows that have not been updated within the last 2 days. However, if I change the query like this: SELECT * FROM `my_table` WHERE DATEDIFF(NOW(), updated) > 2 I get the following e...

mysql command to exchange columns

I ran into a problem where one version of my database has a column that is in the wrong position. Is there a way in mysql to re-index or exchange columns? ...

MySQL: Rewrite MSSQL with correlated subquery in FROM clause

We have a table that contains website page views, like: time | page_id ----------|----------------------------- 1256645862| pageA 1256645889| pageB 1256647199| pageA 1256647198| pageA 1256647300| pageB 1257863235| pageA 1257863236| pageC In our production table, there is currently about 40K rows. We want to generate, for each da...

User configurable forms with php and mysql

An online application we are building (php & mysql) requires users to be able to create their own forms for data capture and record this data in a database, respecting the existing ORM's. If the forms where "hard coded" then we would simply set the db tables up to store the normalised data ourselves however as our users define the form ...

trouble creating a sql statement select statement reference same table twice

Ok, here is setup. Note the code below is SIMPLIFIED version. PHP 5.2 ENGINE: MyISAM table quotes q table users u FROM quotes q LEFT JOIN users u ON q.qid = u.uid Soo... the quotes table references a user (from users table) (the owner of quote) but quotes table ALSO has a field called createdby (the user who created the quot...

What characters ARE allowed when querying a mysql database?

I have a textarea in a form, when I enter special characters in it, I get an error in mysql. (when submitting the form to a php-file which does the work of inserting into mysql) I need to know exactly what characters that aren't allowed, or easier would be, exactly what characters thar ARE allowed, so that I could validate the textarea ...

What would be the best practice to store multiple 2 digit dataset in MySql server

Let say i want to store several dataset ie 78 94 33 22 14 55 18 10 11 44 59 69 79 39 49 29 19 39 And later on i would like to be able run queries that will determine the frequency of certain number. What would be the best way to this? What would be table structure to make a fast query. Please be specific as you can be. ...

MySQL: Get all records that have an id for one year but not another

Hi, I have a table: HOST_ID | ContractYear 1 | 2008 2 | 2008 3 | 2008 1 | 2009 4 | 2009 What I need is a query that will tell me all the HOST_ID's that are in 2009 that are not in 2008. The answer in the example above is HOST_ID=4. Thanks. ...

Python/MySQL fails under Windows

I'm trying to get Python 2.6 to communicate with MySQL Server 5.1, under Windows XP, but I keep getting a strange error, "SystemError: NULL object passed to Py_BuildValue": >>> import MySQLdb as mysql >>> db = mysql.connect(user = "root", passwd="whatever", db="mysql", host="localh ost") >>> cu = db.cursor() >>> cu.execute("show tables"...

Fetch recently watched videos?

I am using MySQL. I have the following table structure: tablename: Videos videoId title description 1 Video title 1 Some description text1 2 Video title 2 Some description text2 3 Video title 3 Some description text3 4 Video title 4 Some description text4 5 Vi...

MySQL Wrong ORDER BY

SELECT `player`.`cid`, `player`.`k`, `player`.`d`, `gg`.`gg_id`, `gg`.`name`, `gg`.`img`, `cc`.`cid`, `cc`.`name`, `cc`.`class`, `cc`.`gg_id` FROM `player` LEFT JOIN `cc` ON `cc`.`cid` = `player`.`cid` LEFT JOIN `gg` ON `gg`.`gg_id` = `cc`.`gg_id` ORDER BY (`k`-`d`) DESC i want to order by the K minus the D values, but im not gettin...

Tips for speeding up this code

Hiya, Can anyone suggest tips or alterations to make this code cleaner and faster? This was the only way I could think of doing it on a Friday evening, but I'm sure there must be a more efficient way of doing it... I know regexs aren't efficient but I can't honestly see how else I can do this, especially if the Postcode data can be an...

Is there any way to let MySQL server 'push' DB updates to a client program?

A typical scenario: imaging a user is feeding data to MySQL, while a client is connected to MySQL remotely. What I want is that, whenever the user update some fields in the DB, this client can immediately be notified. Think this as the 'push-mail' function from Blackberry. What I do NOT want, is that the client has to 'ping' MySQL se...

SQL Plus - Alias type question.

I need to find the book code and book title for each book whose price is greater than the book price for every book that has the type 'HOR'. My table looks like this CREATE TABLE BOOK ( BOOK_CODE CHAR(4) CONSTRAINT BOOK_BOOK_CODE_PK PRIMARY KEY, TITLE VARCHAR2(40) CONSTRAINT BOOK_TITLE_NN NOT NULL, PUBLISHER_CODE CHAR(2) CON...

Sorting and Grouping mySQL Results in html

I have a mysql table with 3 fields: id, client, group and some data. I need to display the results in groups, on a css table, like this: group A - John - Paul - Ringo - George group B - Mick - Keith - Charlie group C - Axl - Slash - Izzy I have to put a while inside another while? I really d...