I'm trying to design a database to record game histories for a game I'm working on. I have 3 different tables: users, gamehistories, and gamescores.
Columns for tables:
users: uid, displayname, email
gamehistories: gid, pubID, start (datetime), end (datetime)
gamescores: gid, uid, score
I am trying to produce the following result...
This one really has me stumped. I have a documents table which hold info about the documents, and a procedures table, which is kind of like a revisions table for each document. What I need to do is write a select statement which gives me all of the documents where all of the procedures have the status "work_in_progress". Here's an exa...
I have mysql database structure like below:
CREATE TABLE test (
id int(11) NOT NULL auto_increment,
title text NULL,
tags text NULL,
PRIMARY KEY (id)
);
data on field tags is stored as a comma separated text like html,php,mysql,website,html etc...
now I need create an array that contains around 50 randomly selected tags...
I'm trying to get all records with date greater then now. I tried this but it doeasnt work:
$all_dates = $this->TourDate->find('all', array('conditions' => array('TourDate.date >=' => 'NOW()'), 'order' => array('TourDate.date ASC')));
If I replace NOW() with the current date it works. Why's that?
...
My table looks like this:
`MyDB`.`Details` (
`id` bigint(20) NOT NULL,
`run_id` int(11) NOT NULL,
`element_name` varchar(255) NOT NULL,
`value` text,
`line_order` int(11) default NULL,
`column_order` int(11) default NULL
);
I have the following SELECT statement in a stored procedure
SELECT
RULE
,TITLE
,SUM(IF(t.PASS...
just want to verify that database partition is implemented only at the database level, when we query a partitioned table, we still do our normal query, nothing special with our queries, the optimization is performed automatically when parsing the query, is that correct?
e.g. we have a table called 'address' with a column called 'country...
Hello everyone,
I have a table called pollData. It will always contain only 1 row. It has columns option1, option2, option3, option4, option5 each of type int. In the beginning, these columns have 0 as their value. How do I add 1 to any column, say option2? I mean do i retrieve the value of that column first, perform addition, and store...
Is it possible to Use cursor in triggers in MySQL? Is it recommended? as someone told me its helpfull to use cursor in triggers for auditing
I need this for auditing...
EDIT
is it helpful to use cursor in triggers for auditing? If Yes then How?
Please help ..
Thank You
...
I have the following tables (removed columns that aren't used for my examples):
CREATE TABLE `person` (
`id` int(11) NOT NULL,
`name` varchar(1024) NOT NULL,
`sortname` varchar(1024) NOT NULL,
PRIMARY KEY (`id`),
KEY `sortname` (`sortname`(255)),
KEY `name` (`name`(255))
);
CREATE TABLE `personalias` (
`id` int(11) NOT NU...
Hi,
here is the "msg" table on mysql
sent_to customer msg read
------- -------- ------ -----
45 3 bla 0
34 4 bla 1
34 6 bla 0
45 3 bla 0
56 7 bla 1
45 8 bla 0
for example user whose id number ...
The goal of this query is to get a total of unique records (most recent per IP, by IP) per ref ID.
SELECT COUNT(DISTINCT ip), GROUP_CONCAT(ref.id)
FROM `sess` sess
JOIN `ref` USING(row_id)
WHERE sess.time BETWEEN '2010-04-21 00:00:00' AND '2010-04-21 23:59:59'
GROUP BY ref.id
ORDER BY sess.time DESC
The query works fine, but its using...
I have two tables in a MySQL Database.
Users table and Users Meta Table
I am looking for a way to get all the information out of both tables with one query. But without repeating the information from Users table.
This is all information relating to the users id number as well. So for example user_id = 1.
Is there a way to query the d...
I'm using the extra() modifier in a view.
(See http://docs.djangoproject.com/en/1.1/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none )
Here's the the code:
def viewname(request)
...
exact_matchstrings=[]
exact_matchstrings.append("(accountprofile.first_name LIKE '"...
Is it possible to use a column value from an outer select within a joined subquery?
SELECT table1.id, table2.cnt FROM table1 LEFT JOIN (SELECT COUNT(*) as `cnt` FROM table2 where table2.lt > table1.lt and table2.rt < table1.rt) as table2 ON 1;
This results in "Unknown column 'table1.lt' in 'where clause'".
Here is the db dump.
CRE...
I need to retrieve data from within a specific date range.Anybody can help me to create a query to getting the information within date range 12-12-2009 to 12-15-2009 from a mysql table.(including 12 and 15)
...
I have following complex query which I need to use. When I run it, it takes 30 to 40 seconds. But if I remove the order by clause, it takes 0.0317 sec to return the result, which is really fast compare to 30 sec or 40.
select DISTINCT media.*
, username
from album as album
, album_permission as permission
, user a...
Hello i have a products table that contains normal products and configurable product
It has a basic stucture of:
id
name
price
configurable ('yes', 'no')
id_configuration
Normal products have configurable no and 0 as id configuration, and configurable products have it set to yes and have the same id_configuration value.
The curren...
how do I get all the records for latest date. The date filed in my db is called recordEntryDate and it is in this form 2010-01-26 13:28:35
Lang: php
DB: mysql
...
I originally started by selecting customers from a group of customers and then for each customer querying the records for the past few days and presenting them in a table row.
All working fine but I think I might have got too ambitious as I tried to pull in all the records at once having heard that mutiple queries are a big no no.
here...
One thing I always wonder while writing query is that am I writing most optimized query or not? I know certain things like:
1) using SELECT field1, filed2 instead of SELECT *
2) Giving proper indexes to the tables
but I am sure there are more things that should be kept in mind for writing queries, since most of the database can only ...