I have three tables that I need to join together and get a combination of results. I have tried using left/right joins but they don't give the desired results.
For example:
Table 1 - STAFF
id name
1 John
2 Fred
Table 2 - STAFFMOBILERIGHTS
id staffid mobilerightsid rights
--this table is empty--
Tabl...
I never understood this: in web development whe[n|re] does it make sense to fetch results one by one?
I mean, why should I use PDOStatement->fetch*() when I can use PDOStatement->fetchAll()?
...
I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to sort the results depth-first, as one would expect with threaded forum replies.
id | parent_id | matpath | created
----+-----------+---------+----------------------------
2 | 1 | 1...
I'd like to get the total count of results and top n rows of some query - is it possible
in one statement?
I'd expect the results as:
count(..) column1 column2
125 some_value some_value
125 some_value some_value
Thank you in advance!
...
I'm creating an SQL setup script and I'm using someone else's script as an example. Here's an example of the script:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[be_Categories](
[CategoryID] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF_be_Categories_CategoryID] DEFAULT (newid()),
[CategoryName...
I have a scenario which I'm a bit stuck on. Let's say I have a survey about colors, and I have one table for the color data, and another for people's answers.
tbColors
color_code , color_name
1 , 'blue'
2 , 'green'
3 , 'yellow'
4 , 'red'
tbAnswers
answer_id , favorite_color , least_favorite_...
I am about to upload my website onto a VPS.
It is a classifieds website, where all data is stored in MySql and Solr.
I wonder if when using MySql:s cache, the server will slow down?
Ie, if somebody makes a search for the first time, and MySql is to cache the query, will the caching make the server slower than if it would not cache any...
For my application most of my SQL queries return a specified number of rows. I'd also like to get the maximum possible number of results i.e. how many rows would be returned if I wasn't setting a LIMIT.
Is there a more efficient way to do this (using just SQL?) than returning all the results, getting the size of the result set and then...
Can anybody help me with the syntax?
insert into history (company,partnumber,price)
values ('blah','IFS0090','0.00')
if company NOT IN ('blah','blah2','blah3','blah4','blah4')
and partnumber='IFS0090';
Background:
I have a history table which stores daily company, products and prices. But sometimes a company will remove itself f...
I am trying to design a sqlite database that will store notes. Each of these notes will have common fields like title, due date, details, priority, and completed.
In addition though, I would like to add data for more specialized notes like price for shopping list items and author/publisher data for books.
I also want to have a few gen...
Hello,
I am trying to execute a query on a table in my SQL Server 2008 database. I have a stored procedure that uses five int parameters. Currently, my parameters are defined as follows:
@memberType int,
@color int,
@preference int,
@groupNumber int,
@departmentNumber int
This procedure will be passed -1 or higher for each parameter....
Problem
Am looking to apply the y = mx + b equation (where m is SLOPE, b is INTERCEPT) to a data set, which is retrieved as shown in the SQL code. The values from the (MySQL) query are:
SLOPE = 0.0276653965651912
INTERCEPT = -57.2338357550468
SQL Code
SELECT
((sum(t.YEAR) * sum(t.AMOUNT)) - (count(1) * sum(t.YEAR * t.AMOUNT))) /
...
Besides being unsafe... I get no error message, but the row is not updated. The rows integer is set 1 following the query, indicating that 1 row was affected.
String query = "UPDATE contacts SET contact_name = '" + ContactName.Text.Trim() + "', " +
"contact_phone = '" + Phone.Text.Trim() + "', " +
"contact_fax ...
Hey, I'm just looking for some rough guidance here on the feasibility of a project.
I have say a few thousand text documents and I want to create a web based system to serve them up to users in a OS X application.
It's just a tiny aside for my family's small business, so it doesn't need to be amazing at the moment, we just want to ...
So I know the convention for naming M-M relationship tables in SQL is to have something like so:
For tables User and Data the relationship table would be called
UserData
User_Data
or something similar (from here)
What happens then if you need to have multiple relationships between User and Data, representing each in its own t...
how do I find, with full text search all words that match 'ability' mask, like "suitability" and "dependability", etc? is that possible?
...
Code
The following code calculates the slope and intercept for a linear regression against a slathering of data. It then applies the equation y = mx + b against the same result set to calculate the value of the regression line for each row.
How can the two queries be joined so that the data and its slope/intercept are calculated withou...
I've been beating my head on the desk trying to figure this one out. I have a table that stores job information, and reasons for a job not being completed. The reasons are numeric,01,02,03,etc. You can have two reasons for a pending job. If you select two reasons, they are stored in the same column, separated by a comma. This is an examp...
Hi. I'm a sql newbie, I use mssql2005
I like to do join Action depnding on input parameter.
CREATE PROCEDURE SelectPeriodicLargeCategoryData
@CATEGORY_LEVEL CHAR(1),
@CATEGORY_CODE VARCHAR(9)
AS
...
JOIN CATEGORY_AD_SYS CAS WITH(NOLOCK)
ON CA.CATEGORY_ID = [[[[[ HERE ]]]]
above the sql.
if @CATEGORY_LEVEL = 'L' the...
i`m doing
string sql = "select * from publisher where title like "'"+tbproperty.text+";
but it`s not working!
regards..
...