What does adding ranked to a mysql query do?
I'm trying code from this post
SELECT * FROM ( SELECT @row := @row +1 AS rownum, [column name] FROM ( SELECT @row :=0) r, [table name] ) ranked WHERE rownum % [n] = 1
...
Is it possible to keep all my database related configuration (hostnames, usernames, passwords, and databases) as well as the function to connect to and select the correct database in a seperate class?
I tried something like this:
class Database
{
var $config = array(
'username' => 'someuser',
'password' => 'somepass...
Which one of the following ways would you use in declaring Primary Keys by Postgres?
#1
CREATE TABLE user(
user_id PRIMARY KEY,
...
)
#2
CREATE TABLE user(
user_id NOT NULL,
...
CONSTRAINT user_pk PRIMARY KEY(user_id);
)
...
How would I programmatically go about limiting the access of a database in SQL Server 2000 to the database owner for that database? Example... if I right-click "Properties" on the "Northwind" database in Enterprise Manager, the Owner is listed as sa. How would I limit access for this database to just the sa login?
...
How do you read the following line of code?
The code is from SO by John Saunders. (Please add a link to it if you find it)
SET search_path TO so,"$user", public;
Context
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE;
CREATE SCHEMA SO
SET search_path TO so,"$user", public; /// here
...
I read the line as "set...
I have a database that contains a table of deposits (security deposits, pet deposits, etc) and in certain cases these deposits need to be reduced, i.e. someone purchases supplemental insurance. Should I have a table called say, alter_deposits, that will contain the conditions for reduction as well as the amount or is this something that ...
I am working on a business app (asp.net). Right now I am using sql server. But I plan to support at least mysql and postgresql down the road.
What are the issues that I should consider to avoid future headaches? Especially about datatypes (column types). E.g. I think BIT column is not supported on some dbs so I use tinyint?
I mostly u...
I have noticed a lot of companies use a prefix for their database tables. E.g. tables would be named MS_Order, MS_User, etc. Is there a good reason for doing this?
The only reason I can think of is to avoid name collision. But does it really happen? Do people run multiple apps in one database? Is there any other reason?
...
I've written an app that needs a database. I've been using a local copy of SQL Server on my machine but would like to build a setup for this application that installed it's own database to support the application. I'd rather not have to have the user install SQL on their own and then configure the application.
Can anyone point me in...
If you have an array of record ID's in your application code, what is the best way to read the records from the database?
$idNumsIWant = {2,4,5,7,9,23,56};
Obviously looping over each ID is bad because you do n queries:
foreach ($idNumsIWant as $memID) {
$DBinfo = mysql_fetch_assoc(mysql_query("SELECT * FROM members WHERE mem_id ...
I have two access databases and would like to find a way to copy tables from one
database to the other. The copied table has to keep the same strucure and data.
I already tried to fiddle around with sqlBulkcopy but all information i can found about it
is using sqlBulkCopy to tranfer tables to sql server.
Can I use sqlBulkCopy to copy t...
we are creating a website for hotel booking. we need to store a large number of images. we think it would be a better option to store images in the filesystem and store the path in the database. But do we have to manually save them? We are using web services from another website to get the images. is there a way to save the images dynami...
Let's say you have a million entities persisted into the database.
You want to fire your Drools rules on each persisted entity in order to check on what to do next with them.
What would be the preferable way to do that? Would you prefetch data according to the rules (which would mean that you tie your DAO to your rules), or would you ju...
I have a database table with a field that I need to read from and write to via Hibernate. It is string field, but the contents are encrypted. And for various reasons (e.g. a need to sort the plain text values), the encrypt/decrypt functions are implemented inside the database, not in Java.
The problem I'm struggling with now is finding ...
I am implementing a contest system in which the user has to choose the correct answer of multiple questions. Each week, there is a new set of questions.
I am trying to find the correct way to store the user participations in a database. Right now I have the following data model:
Participation Week
+--------------+ ...
Hi, I have a table with number of page views per day. Something like this:
+------+------------+------+
| id | date | hits |
+------+------------+------+
| 4876 | 2009-07-14 | 4362 |
+------+------------+------+
| 4876 | 2009-07-15 | 1324 |
+------+------------+------+
| 7653 | 2009-06-09 | 5643 |
+------+------------+------+
...
I have had difficulties in finding a tool by which I could make a similar diagram as the following
where
aloitussivu = homepage
yritysinfo = about
yleiskuva = general
tunnussivu = user
rekisteröintisivu = register
...
I use VP-UML. However, I have not managed to create such a diagram by it.
The diagram looks like Activity diagram,...
This seems like a duplicate even as I ask it, but I searched and didn't find it. It seems like a good question for SO -- even though I'm sure I can find it on many blogs etc. out there. SO will have more of a debate than you can get on a blog.
I'm running into an issue with a join: getting back too many records. I think of this as "exp...
I need to find out the total number of records that were created on a given day.
e.g.
ID CreatedDate
1 17/07/2009
2 12/07/2009
3 17/07/2009
4 05/07/2009
5 12/07/2009
6 17/07/2009
Output:
3 Records were created on 17/07/2009
2 Records were created on 12/07/2009
1 Record was created on 05/07/2009
EDIT
Upon testing the second su...
This is more of a "why do things work this way" question rather than a "I don't know how to do this" question...
So the gospel on pulling associated records that you know you're going to use is to use :include because you'll get a join and avoid a whole bunch of extra queries:
Post.all(:include => :comments)
However when you look at ...