mysql

Query to select intervals from a table

I have a table that defines time intervals. _______________________________ | id | description | start_date | |____|_____________|____________| | 1 | First | NULL | | 3 | Third | 2009-12-18 | | 5 | Second | 2009-10-02 | | 4 | Last | 2009-12-31 | |____|_____________|____________| It stores only the s...

How use a relational database as a document-based one?

For make a document managment system, I'm looking at document stores like MongoDB, but because I have more experience with regular databases (Firebird, Sql Server, Mysql) I wonder if is possible model a document store on top a relational one. The advantages about a document store, schema less: Fit well to the task of store arbitrary m...

Using SELECT in this SQL statement isn't working...

My table is organised like this: With key as the primary field. The records shown are in the renamed table. I need to get out the original_name by the key. The key coluimn is the primary key of the table. This is my SQL code: SELECT original_name FROM `renamed` WHERE key='fb166' However, it does not return any results. I have tri...

Update MySQL database from SQL Server in different domain

I am SQL Server developer and the current assignment is little different than what I have done in past. I found Stack Overflow very promising for my problem. I am working on the SQL Server 2005 database for the internal application for my client and the client also got the public facing web application with MySQL database. I do not have ...

Zend_Db: How to get the number of rows from a table?

I want to find out how many rows are in a table. The database that I am using is a MySQL database. I already have a Db_Table class that I am using for calls like fetchAll(). But I don't need any information from the table, just the row count. How can I get a count of all the rows in the table without calling fetchAll()? Solution: This ...

mysql join query using like ?

Hey I have been trying to get this working for quite a while now but it just doesn't seem to work, maybe it is is not even possible, what i am wanting to do is to perform a mysql join query using like, such as this example i found... SELECT * FROM Table1 INNER JOIN Table2 ON Table1.col LIKE '%' + Table2.col + '%' but it just doesn't ...

How Do I Select the Entire Record When Using MAX() With GROUP BY

Using MYSQL I would like to refactor the following SELECT statement to return the entire record containing the newest invoice_date: > SELECT id, invoice, invoice_date FROM invoice_items WHERE lot = 1047 id invoice_id invoice_date ----------------------------------- 3235 1047 2009-12-15 11:40:00 3295 1047 2009-...

Php lottery issues multi winner problems

I have created a lottery script in php. My problem is now selecting more then one winner. Because it is possible for players to have the same number on their tickets. Here I am supplying the two table structures and the source code. lotto_game { id(int) jackpot(int) status(varchar10) pick_1(int) pick_2(int) pick_3(int) pick_4(int...

How does MySQL store rows on disk?

I'm looking for documentation on how MySQL stores data on disk, in particular InnoDB and MyISAM. I took a database course back in college (and wrote a primitive database) so I have a general idea. I could ask a bunch of questions here about how various types are stored in rows, and how rows are stored on disk, or go whole-hog and just ...

MySQL/PHP: How to list results in groups but limit the DB queries required

I have a database as follows: --------------------------------------------------------------- | module_name | category | content | --------------------------------------------------------------- | module1 | category1 | content | | module2 | category1 | c...

Shorter REGEXP for MySQL query

I want to do a MySQL query to get the following effect: table_column [varchar] ----------------------- 1|5|7 25 55|12 5 3&5 5|11 I want a reliable way to get all the values where 5 is the complete value. So, for example, if I do a REGEXP query for the number 5 on the upper table I would like to get all ro...

How do I list normalised data from MySQL in PHP?

I always struggle with dealing with normalised data, and how I display it. Maybe its because I don't fully understand the normalisation rules, like how to get it fully into Boyce-Codd. Performance is not really an issue at this stage, though maintainability of the schema is. user ID Name 1 Alice 2 Bob 3 Charlie skills ID ...

Is it a good practice to set the default value of some field/column as NULL in MySQL?

What are the disadvantages to do so? ...

MySQL auto-store datetime for each row

Lately I've been doing quite a few projects that require the use of back-end, including MySQL. However I'm quite sick of adding the columns dt_created and dt_modified (which are date time stamps for creation and last modified respectively) to all the tables I have in my database. Everytime I INSERT or UPDATE the database, I will have t...

PHP how to check if a MySQLi query needs to be closed?

I created a simple MySQLi class for a project I'm working on to make it easier and more streamlined to pull from and push to the DB. (also to get more familiar with OOP in PHP) A problem I keep running into is in an effort to make it as efficient as possible. I try to close / free every query / statement / result set. In doing so I get ...

Persisting a new but identical entity with JPA reporting duplicate entry

I have a JPA project connected to a MySQL database where my entity object is mapped to a table with a constraint on 2 columns. That is: @Entity @Table(name = "my_entity") class MyEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private Integer id; @Bas...

Can't get MySQL source query to work using Python mysqldb module

I have the following lines of code: sql = "source C:\\My Dropbox\\workspace\\projects\\hosted_inv\\create_site_db.sql" cursor.execute (sql) When I execute my program, I get the following error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to u...

What Collation is the best for data type INT in MySQL?

When a filed is INT(data type), what should I choose as collation in MySQL? ...

prolog backtracing using mysql

my problem i have a system build in php.in one part of the system i need to make the system can suggest the list of qualfied candidate which the candidate information are from mysql ,,this rule make ussing prolog backtracking technic...? ...

Which third party search engine (free) should I use ?

As the title says, I need a search engine... for mysql searching. My website is PHP based. I was going with sphinx but my hosting company doesn't support full-text indexes! So a search engine to be used without full-text! It should be pretty powerful, and must include atleast these functions below: When searching for 'bmw 520' only ...