My models:
class Student
has_many :grades
has_many :courses, :through => :grades
end
class Grades
belongs_to :student
belongs_to :course
end
class Course
has_many :grades
has_many :students, :through => :grades
end
On my view page, for a student, I need to show all the courses and associated grades (if any)
Student: Joe...
Hello,
I currently have 26 tables in a MYSQL database. My boss wants me to recreate those 26 tables whenever we have a new client, and append a client abbreviation of some sort to those new tables. So for example there's company1~system~users and company2~system~users and so on and so forth.
I'd rather just add a table to the database ...
Jeff Atwood wrote once he found quering database for primary keys, and then getting all relevant fields with an IN clause is double as quick as its single-sql counterpart.
I wonder if this applies to all situations, and if not, what are the cases when it still provides significant room for improvement in terms of performance?
Furthermo...
So I basically wanna display this (whole row in ONE column):
I like [type column] cake with [icing column] and a [fruit column].
The result should be:
Cake_Column
I like chocolate cake with whipped_cream and a cherry.
I like strawberry cake with vanilla_cream and a lemon_slice.
etc.
etc.
I need some sort of TO_CHAR statement tha...
Hello
I use mysql.data in my visual basic 2008 project. When I build my app and look into the RELEASE folder, I need the .exe.config file to run my app orless it would not work. How would I incorporate this into my application so that I don't need it when I debug my app?
Thanks,
Kevin
...
I have tried the obvious "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED", but my simple stored procedure still gets blocked while doing a SELECT MAX on a PRIMARY KEY while updates are going on (when running simultaneously with certain complex update transactions that I do not want to modify) -- ultimately running into Deadlock...
I am trying to convert from using MySQL to using PostgreSQL. I have this type of structure:
User(entity) -> Follow -> Business(entity) -> Story
The user needs to see all the news updates put out by the businesses they follow. The following query works great with MySQL because it simply shows all associated stories and groups by the sto...
I'm having an issue bending my head around this one.
I have a table with the following structure. Contains about 5 million rows.
Id bigint primary identity, auto increment
SKU int
Keyword nvarchar(200)
KeywordType nvarchar(1)
The table is broken down into all possible keywords, in multiple languages for a given SKU. Thus for example,...
Using a query like below you can fetch rows in which the color of the id is blue, purple, green, white, and black.
SELECT t1.id, col
FROM extra as e INNER JOIN your_table as t1 USING ( id )
CROSS JOIN your_table as t2 USING ( id )
CROSS JOIN your_table as t3 USING ( id )
CROSS JOIN your_table as t4 USING ( id )
CROSS JOIN your_table as ...
I'm using System.Data.SQLite to save data to database. In table there are 2 columns defined as float. However when I save data to DB it saves only integer part.
12.2345 => 12
11.5324 => 11
(I don't know how exactly it rounds, it just rounds)
Yes I'm sure I'm using floats in my application, and I'm sure that CommandText contains float n...
Hi everyone,
I'm using MySQL 5, and I need to do this sentence to get the results. It's the first attempt when I think about it. I know there are several ways to improve it, but I want to get your opinions first:
SELECT p.id, p.image, p.lat, p.lng,
p.category_id, p2.title, p2.description, c2.name
FROM place p
LEFT JOIN place_tr...
I have a problem. Actually in our application, earlier the customer was allowed to pay 3 installemnt per month but now it can be any number . So I have the earlier query
declare @tbl table([MonthName] varchar(50), [Installment] int)
insert into @tbl select 'Jan',100 union all
select 'Jan',200 union all select 'Jan',300 union all
sele...
Work on SQL Server 2000.i want to send birthday wishes to all customers whose birthday matches the current day.I have created a database Customers with a table called CustomerDetails with the following fields
ID
Name
BirthDate
Email
I have written the SQL script shown below. The SQL script loops through the CustomerDetails table and...
Guys, I'm trying to call a function from a form within the same .php file, but when the Submit button is hit, the table doesn't get generated.
Here's the code:
<p>
<?php
function selectQuery()
{
$con = mysql_connect("localhost","readonly","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_s...
Hello
I haven't done SQL in a while, so I need to freshen up on things. I have a SQL Database running on my computer, and my server is localhost. I made an app in VB.Net that connects to this database. Everything works fine and all, until I distrubute my app to another person. When they try to connnect it doesn't seem to work for them....
WhenI call this stored procedure:
ALTER PROCEDURE [dbo].[GetSorted]
(
@OrderByColumn nvarchar(256)
)
AS
SET NOCOUNT ON
SELECT itDocs.AddedDate, itDocs.AddedBy FROM itDocs
ORDER BY
CASE WHEN @OrderByColumn='AddedDate' THEN itDocs.AddedDate
WHEN @OrderByColumn='AddedBy' THEN itDocs.A...
Scenario
I am building a database that contains a series of different tables. These consist of a COMMENTS table, a BLOGS table & an ARTICLES table. I want to be able to add new items to each table, and tag them with between 0 and 5 tags to help the user search for particular information that is relevant more easily.
Initial thoughts fo...
Hi all
well this is the first time in this forum so I'II be clear about my question and thanks in advance
I'll create a software in C#, this app takes a CSV file (about 73,000 lines). This files comes from another system, also the CSV file can change, what's that means? the CSV file can change in one line ( the data ) or can have more ...
I need a similar function to Oracle WM_CONCAT in SQL Server, which returns a comma separated list of whatever field you pass it as argument. For example, in Oracle,
select WM_CONCAT(first_name) from employee where state='CA'
returns "John, Jim, Bob".
How can I do this in SQL Server?
Thanks
...
Hi all!
I want to be able to store a decimal value in one column, and in the other column to store an int that represents the option (will explain):
should be base -%
should be base -absolute
should be base +%
should be base +absolute
1 & 2 is a discount
3 & 4 is an upcharge
1 & 3 reduces/raises the amount by percentage (i.e. amount *...