Hi All,
I'm trying to work out a query that self join itself on a table using the eventnumber. I've never done a self join before.
What i'm trying to query is when a client has started off in a city which is chester to see what city they moved to. But I dont want to be able to see if they started off in another city. I would also like...
<hyperbole>Whoever answers this question can claim credit for solving the world's most challenging SQL query, according to yours truly.</hyperbole>
Working with 3 tables: users, badges, awards.
Relationships: user has many awards; award belongs to user; badge has many awards; award belongs to badge. So badge_id and user_id are foreign...
i have a date (eg: 2010-04-17 ) i need the date of after 20 days from this date
How to get the date after 20 days i.e next month some date.
either in sql or in c#
...
Hi,
Suppose, I am about to start a project using ASP.NET and SQL Server 2005. I have to design the concurrency requirement for this application. I am planning to add a TimeStamp column in each table. While updating the tables I will check that the TimeStamp column is same, as it was selected.
Will this approach be suffice? Or is there ...
How to add data from one table to another table with new data in sql
...
Im wondering whats the best way of storing different types of users in my database.
I am writing an application that has 4 main user types (admin, school, teacher, student).
At the moment I have a table for each of these but i'm not sure thats the best way of storing user information.
For instance... Allowing students to PM other stude...
I'm trying to find an efficient way to find the rank of an object in the database related to it's score. My naive solution looks like this:
rank = 0
for q in Model.objects.all().order_by('score'):
if q.name == 'searching_for_this'
return rank
rank += 1
It should be possible to get the database to do the filtering, using order_...
I'm doing some custom database work for a module for Drupal and I get the following SQL error when trying to create my table:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL, rooms INT DEFAULT NULL, adults INT DEFAULT NUL...
I have a table with several records. There is an id field. I would like to select the record with the most recent id (i.e. the ighest id).
Any ideas?
...
This is a dumbed down version of the real table data, so may look bit silly.
Table 1 (users):
id INT
username TEXT
favourite_food TEXT
food_pref_id INT
Table 2 (food_preferences):
id INT
food_type TEXT
The logic is as follows:
Let's say I have this in my food preference table:
1, 'VEGETARIAN'
and this in the users table:
1, '...
I have a db schema which looks something like this:
create table user (id int, name varchar(32));
create table group (id int, name varchar(32));
create table group_member (group_id int, user_id int, flag int);
I want to write a query that allows me to so the following:
Given a valid user id (UID), fetch the ids of all ...
Hi,
I an SQL SELECT statement I need to extract the name of two teams, taking both teams from the same table. Eg Below
SELECT sport_activity_id, (team A), (team B), date, time
FROM sportactivity, teams
WHERE competition_id_fk = 2
For (team A) and (team B) I have an team_id, which is a FK for the table 'teams'
Is it possible to get...
I have two possible queries, both giving the result set I want.
Query one takes about 30ms, but 150ms to fetch the data from the database.
SELECT
id
FROM
featurevalues as featval3
WHERE
featval3.feature IN (?,?,?,?)
AND
EXISTS
(
SELECT
1
FROM
product_to_value,
...
hey all,
im trying to transfer my database from local machine to server, im using the publish to provider wizard in visual web developer to generate a scrip, im then using the generated script on the serever database. i keep getting the following error can some one please tell where im going wrong
Msg 468, Level 16, State 9, Procedure ...
For example, I always generate an auto-increment field for the users table, but I also specify a UNIQUE index on their usernames. There are situations that I first need to get the userId for a given username and then execute the desired query, or use a JOIN in the desired query. It's 2 trips to the database or a JOIN vs. a varchar inde...
So I'm working on just a learning project to expose myself to doing some things I do not get to do at work. I'm just making a simple bug and case tracking app (I know there are a million this is just to work with some tools I don't get to). So I was designing my database and realized I've never actually used Foreign Keys before in any of...
I have two tables set up similar to this (simplified for the quest):
actions-
id - user_id - action - time
users -
id - name
I want to output the latest action for each user. I have no idea how to go about it.
I'm not great with SQL, but from what I've looked up, it should look something like the following. not sure though.
SEL...
i want to fetch information from the database using objects.
i really like this approach cause this is more OOP:
$user = Doctrine_Core::getTable('User')->find(1);
echo $user->Email['address'];
echo $user->Phonenumbers[0]->phonenumber;
rather than:
$q = Doctrine_Query::create()
->from('User u')
->leftJoin('u.Email e')
->l...
Hi,
there is any pastebin-like php open source system without sql? I want to install it on localhost and dont want to backup sql.
edit: Highlighting as much as possible languages (as pastebin.com).
...
Can anybody please spot my error, this should be a legal query in SQL shouldn't it??
Unknown column u.usr_auto_key in the ON clause
This is the database schema:
User: (usr_auto_key, name, etc...)
Setting: (set_auto_key, name etc..)
User_Setting: (usr_auto_key, set_auto_key, value)
And this is the query...
SELECT
...