mysql

How do I do a 'group by' for a datetime when I want to group by just the date?

That's a really awkward title :) I need to write a report that generates a list of declines by date. The date is store as a datetime field and is returning the number of declines by datetime. Here's my SQL: select ps.date_scheduled, count(*) from payments_schedule ps left join invoices i on i.invoice_id=ps.invoice_id left join orders...

testing python applications that use mysql

I want to write some unittests for an application that uses MySQL. However, I do not want to connect to a real mysql database, but rather to a temporary one that doesn't require any SQL server at all. Any library (I could not find anything on google)? Any design pattern? Note that DIP doesn't work since I will still have to test the inj...

Multiple tables in nested sets hierarchy

I have a number of distinct items stored in different MySQL tables, which I'd like to put in a tree hierarchy. Using the adjacency list model, I can add a parent_id field to each table and link the tables using a foreign key relationship. However, I'd like to use a nested sets/modified preorder tree traversal model. The data will be use...

Subsonic 3, MySQL T4 template: Structs.tt fails

Hi, Can anyone help? When I try to generate my Structs.cs file, the process is failing with the error, becuase the SchemaName is not being returned by MySQL provider. " Error 3 Running transformation: System.ArgumentNullException: Value cannot be null. Parameter name: objectToConvert at Microsoft.VisualStudio.TextTemplating.ToStr...

Odd batch escape character problem

I'm trying to execute this mysql command from a batch file: mysql -f -utest -ppass db < alter1.sql However, < is an escape character. I tried nesting it in double-quotes, but the double quotes end up appearing as part of the command. I even put a carrot (^) in front of it, LOOKS fine in the prompt window, but mysql still gets that ^ ...

MySQL 5.0: Output BLOB data in (well-formed) XML format?

I'm writing a web interface to MySQL that executes a couple queries and returns some XML data with the results of the queries. Right now, the table the query is running on has three LONGBLOB columns (for storing image data and the like). However, when I try to parse the XML, I run into trouble with certain characters in the BLOB columns...

MySql Book recommendation for experienced database developer/designer

Hi, Any recommendations for a solid, comprehensive coverage of MySql for someone who is very experienced database-wise, but needs to get the MySql architecture, differences and peculiarities? thanks, Chris ...

Any drawbacks to storing an integer as a string in a database?

I have id values for products that I need store. Right now they are all integers, but I'm not sure if the data provider in the future will introduce letters or symbols into that mix, so I'm debating whether to store it now as integer or string. Are there performance or other disadvantages to saving the values as strings? ...

How does a large MySQL database become efficient?

Do really large (say, 100 million rows) databases regularly get broken up? I'm totally unfamiliar with scaling -anything-, but thought that maybe one database could act as a key to larger chunks of the actual data, becoming an index that would say "Oh yeah, that query needs the 20,000,000-25,000,000 block" and sends the query into that b...

Is there a better way to index multiple columns than creating an index for each permutation?

Suppose I have a database table with columns a, b, and c. I plan on doing queries on all three columns, but I'm not sure which columns in particular I'm querying. There's enough rows in the table that an index immensely speeds up the search, but it feels wrong to make all the permutations of possible indexes (like this): a b c a, b a,...

MySQL preventing dual loading

Right guys, I have a MySQL database, using InnoDB on tables, every so often I have to perform a big cron job that does a large batch of queries and inserts. When I run this cron job, for the 5minutes or so that it is running, no other page is able to load. As soon as it is done, the queries are executed and the page loads. The table th...

need help with database creation

Hi! I need to develop a database for A level students, and I'm having problems categorising their subjects. They have 13 subjects altogether and each student can choose as many subjects and any combination from 13 subjects as he likes. How can I cope with this problem? How can I create a database for keeping the record of each student...

pgSQL or mySQL is more secure?

I want to know which database is more secure: mysql or pgSQL. Which ones support stored procedures? What are the advantages of one over the other? ...

How to maintain subcategory in MYSQL?

I am having categories as following, Fun Jokes Comedy Action Movies TV Shows Now One video can have multiple categories or sub categories, let's say VideoId: 23 is present in Categories Fun, Fun->Comedy, Action->TV Shows but not in Action category. Now I am not getting idea that hwo should I maintain these categories in Database....

Insertion in Mysql

Hi friends let me know the way to the issue as follows....... i am trying to insert one table into another table as its column value.... let us say table1 contains 2 columns and table2 contains 3 columns now i need to insert the table1 into the table2 as a value of 3 column,so that in that column table1 should be present.This is perticul...

How to concatenate values from MySQL SELECT

Let's say I have SELECT name FROM table which gives me something like foo bar baz and I need to join all the values, to make it into one string like foo bar baz so I guess it would be something like foreach row in (select ...) var += row but I have absolutely no idea how to write it in MySQL. ...

Optimize MySQL query to avoid "Using where; Using temporary; Using filesort"

Hey all, I built a custom forum for my site using MySQL. The listing page is essentially a table with the following columns: Topic, Last Updated, and # Replies. The DB table has the following columns: id name body date topic_id email A topic has the topic_id of "0", and replies have the topic_id of their parent topic. SELECT SQL_CA...

How to get the latest 2 items per category in one select (with mysql)

My data looks like the following: id|category|insertdate|title.... -------------------------------- 1|1|123|test 1 2|1|124|test 2 3|1|125|test 3 4|2|102|test 4 5|2|103|test 5 6|2|104|test 6 What I try to accomplish is get the latest 2 entries per category (as in order by insertdate DESC), so the result should be: id|.... ---- 3|......

create database with specific data file location in Mysql for one database at runtime

Hi All, Can anyone give any input on how to create database in mysql where it should create its data file at runtime instead of storing it on default location specified in my.cnf. Is there any way for doing this in mysql anyone come across. Thanks in advance. ...

I need to have a field which value would be the id of the item, how can I achieve this?

I'm making an insert statement, the id field has auto_increment, another field must get the exact same value of the id field. All I can think of is to create an hash, save it in the insert, then search for it with a select, retrieve the id and then insert it in the proper field. I am also aware of the LAST_INSERT_ID() command, but I ha...