mysql

Can i create nested tables on MySql?

for example,access example db, every student record have a nested table about guardians. http://img101.imageshack.us/img101/9881/53882937.jpg ...

Determining values based on the count of that item in

I have two tables. ticket & ticketlist. The sold out column in the ticket table needs to be 1 if that item is sold out. Table ticket needs to be soldout when the count for that item in table ticketlist is 2. ticket ticketid, quantity, soldout 21 2 1 ticketlist ticketlistid, ticketid 3 2...

Best practices for user physical location (input, data type, display and validation)

I'm building a web application that requires users to provide their location (similar to the way Facebook does it). I'm not sure on the best way to implement this. I require the ability to search through records of another entity (call it 'events') which also have a physical location attached to it, and match the users in the same or clo...

Why is MySQL seeing 1000.00 as a smaller number than 34.00?

I have 2 products, one is a thousand dollars so for it's price I inserted into the database: 1000.00 and nother thats 34 dollars so I inserted: 34.00 But when I sort the products in order by price (low to high) the $1,000 product comes before the $34 one, why? The query: SELECT * FROM products ORDER BY price ASC; EDIT It's a var...

Restricting the length of a double field in SQL

I don´t have a field as such, but I am making a new field which is the result dividing an existing field, i.e. cost/1.15 Is there a way to restrict the result of this calculation to two decimal places? ...

Simple to advanced SQL queries examples to practice MySQL query performance optimization

Hi, Looking for websites/books SQL queries from simple to advance (queries optimization and performanance etc.. ) questions and examples to exam for MySQL Job. Thanks ...

restarting auto incrementing

I have a table with an id field, set to auto increment. However, say I insert 10 records, and then empty the table, the first new record will be id number 11. Why is this, and is there a way to prevent it from happening? ...

Preventing duplicates in an SQL query?

Is there an easy way when inserting a new record to make it fail if one of the fields is a duplicate of one of the other fields? I don´t want the field to be a primary key or anything like that... ...

MySQL Query Design for Latest Post per Forum

Hello, i have this 3 tables forums_forum +-----+--------+-------------+-------+-----+ | fid | name | description | index | cid | +-----+--------+-------------+-------+-----+ | 36 | gdghdf | hjghj | 54 | 5 | | 45 | yutuy | iuyi | 99 | 6 | +-----+--------+-------------+-------+-----+ forums_threads +----+--...

0 , NULL, empty string, Default values - MySql Questions

Does bool value false == 0 and true == 1 Does Null value in varchar, int, date fields == 0? When by default in mysql values == 0 or NULL or empty string? ...

Set IF statements to write something or not, to a column in MySQL

Is there a way to set an IF statement in MySQL or PHP to write something to a column or not? What I want to do is completely skip a column so that "NULL" is written to it, in case there is no data to be submitted in the column. In case nothing is to be submitted to the database in one column, I want it to be NULL for that record obvious...

I need help using count for a query

Hi all, i need to select A list showing the customer id, title, first name and surname of each customer who has hired a car, sorted alphabetically by customer surname together with a count of the number of bookings each of them has placed. I've done the first part but not sure where to put count for the number of bookings placed. Here...

How to set up my login system?

I'm trying to figure out if it is better to store my user's data in a session cookie (like password, username, etc), and update that cookie only when I change the MYSQL database from my PHP, OR Store the user's username and user ID in a session cookie and reach out to the MYSQL database every time I need to get the user's data. Which ...

Generating reports, such as income/loss etc

I have 2 tables, purchases and sales with each having a date field and a cost field. I want to generate reports of a few different types, for example I want to show profit and loss over each month or year, or to show how often a particular item sold for a given arbitrary time period ( probably based on user input) Is it terribly comple...

Offset MySQL Without Limit

Possible Duplicate: Mysql Offset Infinite rows Is it possible to specify a query in MySQL with a 'offset' but without a 'limit'. For example: SELECT * FROM countries OFFSET 2 Fails, but: SELECT * FROM COUNTRIES LIMIT 8 OFFSET 2 Works fine. I'd like to just specify the offset. Thanks! ...

Python MySQLDB SSL Connection

I set my database to require ssl. I've confirmed I can connect to the db via command line by passing the public key [and have confirmed I can't connect if I do not pass public key] I get the same error in my django app as when I do not pass a key. It seems I've not setup my settings.py correctly to pass the path to the public key. Wha...

How to fill a dataset from a stored procedure using MySql and Mono

I am trying to fill a dataset with the result of a stored procedure using MySql and Mono. The stored procedure takes in some values, creates a new row in a table and then selects some rows. When I try this I get back an empty dataset and my database does not have any new records. I have checked the basics: The Database is running and...

Can I use REPLACE with a WHERE clause in mysql?

The Title really says it all. Something like: REPLACE INTO vips SET active = 0, inactive = 0 WHERE ip = 3494220867 AND proto = "https"; ...

MySQL: Ordering within grouping?

So I have this messages database between members in my CMS. I wanted to change the listing to show people instead of specific messages. Call it "threads" but each thread in the "my messages" page is a member that you've had a conversation with, right? So, I obviously do this with something like this: select id, msgfrom, headline from m...

How to create rss feeds (.xml) for our own dynamic site while using php and mysql?

I've tried every method that I knows but didn't got the solution on "How to create an rss feeds and sitemap for a dynamic site that get updated automatically". ...