sql

SQL Query Data Collect

I have a SQL server table that has a list of Usernames and a list of points ranging from 1 to 10,000. I want to display the number of points in my VB.NET program from the username given. For example, if I type in "john" in the first box the program will give me a message box saying whatever amount of points "john" has. I'm not really s...

Inserting a GROUP BY result into another table

Hello, I was migrating a field to a new table. The new table has three fields. What I tried was INSERT INTO foo VALUES ('', (SELECT bar FROM baz GROUP BY bar), ''); This resulted in an error due to multiple rows resulting from the select. What is the right way to do this? TIA jg ...

Adding items to a JSON encoded array

Hello I am using this solution found on stackoverflow to encode my MYSQL output to a JSON encoded array. $sth = mysql_query("SELECT ..."); $rows = array(); while($r = mysql_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); This works great and produces an output of [{"id":"81","title":"Something Here","start":...

MySQL Field Concatenation

Given the following table structure: CREATE TABLE foo ( ID INT NOT NULL AUTO_INCREMENT, Category INT NOT NULL, Name VARCHAR(50) NOT NULL, PRIMARY KEY (ID)) Containing data: ID Category Name 1 1 Item 1-1 2 2 Item 2-1 3 1 Item 1-2 4 2 Item 2-2 How do I construct a query to return an every possi...

XElement.Descendants("Node") not behaving as expected, returns multiple levels of Descendants

Hello, I have an issue. I have hierarchical XML data such as: <Tree> <Node Text="Stuff" ItemGUID="064a9bf0-0594-47f8-87be-88dd73763c77" > <Node Text="Food" ItemGUID="326f1f7a-d364-4838-9bdc-ce5fd93f88ca" ItemType="2" /> <Node Text="Wines" ItemGUID="950e3ca3-27a1-41fd-89f3-7a8b08633a9f" /> <Node Text="Flowers" ItemGUID="ce...

SQL query - converting rows of a table into columns

I have a weird question of SQL. I have 2 tables, say products(with columns pid and pname) and rules(with columns rid and rname), and these two tables have nothing in common. The product table has 100 rows and the rule table has 16 rows. I need to write a query in such a way that the result that I get has the pname as the first column...

MYSQL Inner Join with 2 ON Clauses

I am trying to setup a simple database in which I have a user and store both their residential and postal address. I have 2 tables Users id (Primary Key) name (Varchar 255) residential_id (foreign key) postal_id (foreign key) Address id (primary key) type (enum of R and P) street (varchar 255) suburb (varchar 255) I am tring ...

DataType Change from Varchar(30) to Varchar(45)

Hi, I need to test a column which changed from varchar(30) to varchar(65). I don't have a access to insert a value into that column.Is there any other way so that i can test the column? ...

SQL for retrieving data from all the rows for a particular id in the list and then call a function?

Any performance issues in the code below: Goal: I want retrieve data from all the rows for a particular id in the list and then call a function a = list of 2000 ids: for (int i = 0; i < a.size; i++) { // Execute query "SELECT * FROM SOME_TABLE WHERE ID = I"; // Use the data and call a function } Any other solution? Is it pos...

How do i merge two or more rows based on their foreign key?

I have three tables which are: A(a1, a2, a3) //This tbl (Table) can have multiple instances of a1, but cause of its dependence on b1, //we have a unique record each time B(b1, a1, b2) //tbl C has a relationship with tbl B through b1. b1 can also have multiple instances, but //sometimes a number of unique records in this table can ti...

Update HttpResponse Every Few Seconds.

My application in Django can create some very big SQL queries. I currently use a HttpRequest object, for the data I need, then a HttpResponse, to return what I want to show the User. Obviously, I can let the User wait for a minute whilst these many sets of queries are being executed and extracted from the database, then return this mon...

unbale to figure out the proper sql query

Hi Guys, I have a tables like this Results ------- id - autoincrement value TestCase - varchar Verdict - varchar AppID - varchar TestCases --------- id - autoincrementr value TestCase - varchar TestCase_container - varchar Basically I am displaying the results in php code. while displaying the ...

SQL Syntax: Create a single table with column names created from data stored over multiple tables

I have created the SQL script below that creates four tables and inserts data into the tables to demonstrate my question (I hope this helps!). This problem arose because originally this data was stored in a single table of 400 columns and it got very unmanageable so I wanted to find a better way to store the parameters: use master G...

How can I call a stored procedure within a SQL User Defined Function

Hi, I have created a User Defined function within a SQL Project. This C# Method needs to be able to call a Stored Procedure within the same database. How would I go about doing this? ...

How can i do this query in sql? count number of category

my table is: name | category | name01 category01 name02 category01 name03 category02 name04 category02 name05 category02 name06 category02 name07 category02 ..... I would like to count for each category the number of name the output i woulk like is something like this (by the example above): category | num category01 2 cate...

How do i go about matching three fields from two tables in order to update the same tables in case of match

Given two tables A and B in a MySQL Database, how can one update a field in a row of table A if and only if certain fields in the fore-mentioned row in table A exactly match fields in a distinct row of table B. The rows in table B must be used once and only once for each comparison. As such, a row in Table B that has fields matching a ro...

How to trasform a microsoft sql server report service in web application

How can i trasform a microsoft sql server report service in web application or something that i can access on the net? thanks to all that would help me ...

SQL Server 05: Reading values from XML datatype in a query

I'm trying to get all of the attributes and node values from XML in a SQL query. I tried doing the following, but I'm missing out few values in the output. Here is what I tried: DECLARE @Details xml SET @Details = '<root> <SelectedCategory CategoryId="101"> <ItemID>120</ItemID> <ItemID>256</ItemID> </SelectedCat...

Split the output rows in groups in SQL Server

I have to divide the rows equally, so here, for example, there are 15 rows. I want to divide equally, which is in three groups, but I want the name to come only in front of the first entry of each group, as shown: DECLARE @NAMES TABLE ( [ID] INT IDENTITY, [NAME] VARCHAR(20) ) INSERT INTO @NAMES SELECT 'NAME1' UNION ALL SELECT 'NAME2' ...

CHAR behavior with trailing spaces.

Given the SQL statements below, I would expect the result of the query to be: |testX|5| |XXXXX|5| This is because the column is a char(5) and I would expect it to insert blank trailing spaces to fill the remaining space in the column since the inserted values are less than five characters. However, the query actually produces the fol...