<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="http://www.daniweb.com/js/rss.xsl"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community
			 - Databases			Solved Articles
					</title>
		<link>http://www.daniweb.com/web-development/databases/solved/_/16</link>
		<description>Our Databases sub-category encompasses everything related to data storage, both for the web and other uses.</description>
		<language>en-US</language>
		<ttl>60</ttl>
		<!-- PubSubHubbub Discovery -->
		<link rel="hub" href="http://daniweb.superfeedr.com/" xmlns="http://www.w3.org/2005/Atom" />
		<link rel="hub" href="http://pubsubhubbub.superfeedr.com/" xmlns="http://www.w3.org/2005/Atom" />
		<link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns="http://www.w3.org/2005/Atom" />
		<link rel="self" href="http://www.daniweb.com/rss/pull/16/solved" xmlns="http://www.w3.org/2005/Atom" />
		<!-- End Of PubSubHubbub Discovery -->
				<item>
			<title>Auto increment vs. GUID</title>
			<link>http://www.daniweb.com/web-development/databases/threads/456336/auto-increment-vs.-guid</link>
			<pubDate>Mon, 10 Jun 2013 14:05:16 +0000</pubDate>
			<description>All, I'm trying to decide if I should use an auto-increment field or GUID field in a database. Either way I get a unique number identifying the record, so I'm not sure what way is best. Any thoughts? Thanks, -Bill</description>
			<content:encoded><![CDATA[ <p>All,</p>

<p>I'm trying to decide if I should use an auto-increment field or GUID field in a database. Either way I get a unique number identifying the record, so I'm not sure what way is best. Any thoughts?</p>

<p>Thanks,<br />
-Bill</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>WDrago</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/456336/auto-increment-vs.-guid</guid>
		</item>
				<item>
			<title>How to make notification when msql column reach a certain number?</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/456182/how-to-make-notification-when-msql-column-reach-a-certain-number</link>
			<pubDate>Fri, 07 Jun 2013 22:46:35 +0000</pubDate>
			<description>Hello, I'm trying to make notification when msql column reach a certain number. For exemple, I have table &quot;items&quot; with products, witch in their structure have columns id, name and quantity, and when column &quot;quantity&quot; reached 5, I want to make automatic notification: - In new table called &quot;notifications&quot; witch ...</description>
			<content:encoded><![CDATA[ <p>Hello,</p>

<p>I'm trying to make notification when msql column reach a certain number.<br />
For exemple, I have table "items" with products, witch in their structure have columns id, name and quantity, and when column "quantity" reached 5, I want to make automatic notification:<br />
- In new table called "notifications" witch will also have id, name and quantity but just with products from table "items" that have number 5 or less.<br />
- Or somehow to make php table that will display products from the table "items" with a quantity less than 5.</p>

<p>Is is possible?</p>

<p>Thank you in advance.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>logicaweb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/456182/how-to-make-notification-when-msql-column-reach-a-certain-number</guid>
		</item>
				<item>
			<title>valid Entity relationship Diagram? </title>
			<link>http://www.daniweb.com/web-development/databases/oracle/threads/455784/valid-entity-relationship-diagram-</link>
			<pubDate>Sat, 01 Jun 2013 23:16:19 +0000</pubDate>
			<description>I'm not sure if this is the right place to ask , but is this erd valid? Or is it unacceptable? Thank you for any help.</description>
			<content:encoded><![CDATA[ <p>I'm not sure if this is the right place to ask , but is this erd valid? Or is it unacceptable?  Thank you for any help.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/oracle/129">Oracle</category>
			<dc:creator>pwolf</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/oracle/threads/455784/valid-entity-relationship-diagram-</guid>
		</item>
				<item>
			<title>Adding/Deleting/Changing an Entry in MySQL</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/455771/addingdeletingchanging-an-entry-in-mysql</link>
			<pubDate>Sat, 01 Jun 2013 19:34:54 +0000</pubDate>
			<description>Hello Guys, During the process of making my website I have been stopped by a problem. Background Info: I am using jQuery sortable lists and I have multiple lists on the site which submit the information to the file that updates them in the database. Problem: If I want to ...</description>
			<content:encoded><![CDATA[ <p>Hello Guys,<br />
During the process of making my website I have been stopped by a problem.</p>

<p>Background Info: I am using jQuery sortable lists and I have multiple lists on the site which submit the information to the file that updates them in the database.</p>

<p>Problem: If I want to move one item to another list, I need to change one field in a MySQL table to correspond with the name of the UL.</p>

<p>This is my file that  submits the information to the database:</p>

<pre><code class="language-sql">&lt;?php 
session_start();
include('config.php');


parse_str($_POST['containersTop'], $containersTopPos);

foreach ($containersTopPos['page'] as $moduleOrderTop =&gt; $moduleIdTop) {
    mysql_query("UPDATE modules SET `order` = '$moduleOrderTop' WHERE `id` = '$moduleIdTop' ") or die(mysql_error());
}

parse_str($_POST['containersMain'], $containersMainPos);

foreach ($containersMainPos['page'] as $moduleOrderMain =&gt; $moduleIdMain) {
    mysql_query("UPDATE modules SET `order` = '$moduleOrderMain' WHERE `id` = '$moduleIdMain' ") or die(mysql_error());
}
?&gt;
</code></pre>

<p>Now, If I move an item from the list main to the list top, the section field in the MySQL table needs to be changed to top and vice versa.</p>

<p>What should I add for it to work like that?</p>

<p>Thanks,<br />
Oskar</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>donoskaro</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/455771/addingdeletingchanging-an-entry-in-mysql</guid>
		</item>
				<item>
			<title>PostqreSQL Duplicate Values WHERE NOT EXISTS</title>
			<link>http://www.daniweb.com/web-development/databases/threads/455241/postqresql-duplicate-values-where-not-exists</link>
			<pubDate>Fri, 24 May 2013 12:09:58 +0000</pubDate>
			<description>I made this code: INSERT into author(authorfirstname1, authorlastname1,authorfirstname2, authorlastname2) select '&quot;.addslashes($_POST['authorfirstname1']).&quot;','&quot;.addslashes($_POST['authorlastname1']).&quot;','&quot;.addslashes($_POST['authorfirstname2']).&quot;','&quot;.addslashes($_POST['authorlastname2']).&quot;' from author where not exists(select authorfirstname1, authorlastname1, authorfirstname2, authorlastname2 from author where author.authorfirstname1='&quot;.addslashes($_POST['authorfirstname1']).&quot;' and author.authorlastname1='&quot;.addslashes($_POST['authorlastname1']).&quot;' and author.authorfirstname2='&quot;.addslashes($_POST['authorfirstname2']).&quot;' and author.authorlastname2='&quot;.addslashes($_POST['authorlastname2']).&quot;' ); The point of this code should be that it checks, if a value allready exists in database and if ...</description>
			<content:encoded><![CDATA[ <p>I made this code:</p>

<pre><code class="language-sql">INSERT into author(authorfirstname1, authorlastname1,authorfirstname2,  authorlastname2) 
    select '".addslashes($_POST['authorfirstname1'])."','".addslashes($_POST['authorlastname1'])."','".addslashes($_POST['authorfirstname2'])."','".addslashes($_POST['authorlastname2'])."'
  from author      
where not exists(select authorfirstname1, authorlastname1, authorfirstname2, authorlastname2 from author 
        where author.authorfirstname1='".addslashes($_POST['authorfirstname1'])."' 
            and author.authorlastname1='".addslashes($_POST['authorlastname1'])."' 
                and author.authorfirstname2='".addslashes($_POST['authorfirstname2'])."' 
                    and author.authorlastname2='".addslashes($_POST['authorlastname2'])."'
                     );
</code></pre>

<p>The point of this code should be that it checks, if a value allready exists in database and if it doesnt, then it enters it.<br />
This '".addslashes($_POST['authorlastname2'])."' represents an input, but could easyly be replaced with '%myentereddata%'</p>

<p>My problem is that it doesnt do anything...doesnt even give error message, its success, but it doesnt enter data if data doesnt exist in db allready and not sure if it stops entering data if data exists.</p>

<p>So I would be thankful if someone could help me to solve the problem with this code or give another example how to do it differently, so that it would work.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>nao.chungs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/455241/postqresql-duplicate-values-where-not-exists</guid>
		</item>
				<item>
			<title>Update Table - Need to Know Which Update for Future Queries</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/455178/update-table-need-to-know-which-update-for-future-queries</link>
			<pubDate>Thu, 23 May 2013 14:21:10 +0000</pubDate>
			<description>Hi All, I'm a little stuck with one table's design. I have a table called tblConference_Board that will be updated approximately 3 to 4 times per year. The following is my table design: `CB_ID int (PK)` `CB_Mnemonic_ID int (FK)` `CB_Value decimal (18,10)` `CB_Year int` `CB_Quarter int` This table is loaded ...</description>
			<content:encoded><![CDATA[ <p>Hi All,</p>

<p>I'm a little stuck with one table's design.</p>

<p>I have a table called tblConference_Board that will be updated approximately 3 to 4 times per year.  The following is my table design:<br /><code>CB_ID int (PK)</code><br /><code>CB_Mnemonic_ID int (FK)</code><br /><code>CB_Value decimal (18,10)</code><br /><code>CB_Year int</code><br /><code>CB_Quarter int</code><br />
This table is loaded from a staging table called tblConference_Board_Staging.</p>

<p>When there is an update (say in the spring), the values will either be in quarters or annual values.  The year range has been consistently the same and usually starts from 1961 to 2035.  When the next update comes (in the summer), the yearly range will be the same but the actual values will change.  What I'm stuck on is how to determine which data set is from which update?  I thought that another field like maybe <code>CB_Modified date</code> which would populate with the date that update takes place would be a good idea but that way may be tricky to query after the updates.</p>

<p>It's hard for me to summarize my question but it should be something like: How do I populate my table and know which values represent which update?  I'm really hoping someone can make sense of my confusion and if you require more information please ask.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>Stuugie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/455178/update-table-need-to-know-which-update-for-future-queries</guid>
		</item>
				<item>
			<title>CrossTab Query</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/455157/crosstab-query</link>
			<pubDate>Thu, 23 May 2013 09:57:21 +0000</pubDate>
			<description>Need help! As you can see, I'm working with a crosstab report that will display the product's &quot;Total Sales&quot; or &quot;Quantity Sold&quot; on a particular year in a monthly basis. Now my problem is, I can't figure it out how I can display the monthly total sales or quantity sold ...</description>
			<content:encoded><![CDATA[ <p>Need help!</p>

<p>As you can see, I'm working with a crosstab report that will display the product's "Total Sales" or "Quantity Sold" on a particular year in a monthly basis. Now my problem is, I can't figure it out how I can display the monthly total sales or quantity sold for a particular product on a grid. I've tried using WHILE statement on SQL but still I wasn't able to get the ideal output.</p>

<p>Here is my SQL Query:</p>

<pre><code class="language-sql">DECLARE @Month int
SET @Month =1

WHILE (@Month &lt;= 12)
BEGIN 
SELECT P.Name AS 'Product Name'
    ,SUM(SOIL.QuantityDisplay) AS 'Qty'
    ,SUM(UnitPrice) AS 'Amount'
FROM BASE_Product P
    INNER JOIN SO_SalesOrderInvoice_Line SOIL
    ON SOIL.ProductId = P.ProductId
WHERE DATEPART(m, SOIL.CreatedDateTime) = @Month
    AND DATEPART(YY, SOIL.CreatedDateTime) = 2013
GROUP BY P.Name, SOIL.QuantityDisplay, SOIL.UnitPrice
SET @Month += 1
END
</code></pre>

<p>Please enlighten me what's wrong!<br /><img src="/attachments/fetch/L2ltYWdlcy9hdHRhY2htZW50cy8zLzkxYzI1MzI4NjI3MzkxY2ViY2JkNWY3YmI5ZDMyNTlkLlBORw%3D%3D/500" alt="91c25328627391cebcbd5f7bb9d3259d" title="91c25328627391cebcbd5f7bb9d3259d" /></p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>draven07</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/455157/crosstab-query</guid>
		</item>
				<item>
			<title>Monthly to Quarter to Annual</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/454842/monthly-to-quarter-to-annual</link>
			<pubDate>Fri, 17 May 2013 20:53:29 +0000</pubDate>
			<description>Hi All, I have a table that holds monthly data in it. I need to average that data into Quarterly and Annual data but I'm not sure how to go about that. For annual I tried something like: SELECT TOP (100) PERCENT b.vSeries_Type as [Description],b.vSeries_Number as [CANSIM], Year(a.IPI_Ref_Date)as [Year], avg(a.IPI_Value) ...</description>
			<content:encoded><![CDATA[ <p>Hi All,</p>

<p>I have a table that holds monthly data in it.  I need to average that data into Quarterly and Annual data but I'm not sure how to go about that.  For annual I tried something like:</p>

<pre><code class="language-sql">SELECT     TOP (100) PERCENT b.vSeries_Type as [Description],b.vSeries_Number as [CANSIM], Year(a.IPI_Ref_Date)as [Year], avg(a.IPI_Value) as [IPI]
FROM         dbo.tblIPI AS a INNER JOIN
                      dbo.tblVSeriesList AS b ON a.IPIvSeries_ID = b.vSeries_ID AND (b.vSeries_Number = 'v53384920' OR
                      b.vSeries_Number = 'v53384879' OR
                      b.vSeries_Number = 'v53433827' OR)
group by b.vSeries_Type,b.vSeries_Number,a.IPI_Ref_Date
ORDER BY b.vSeries_Number asc
</code></pre>

<p>However the output is definitely not Annual, I don't know exactly what the calculation did.  Can someone point me in the right direction?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>Stuugie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/454842/monthly-to-quarter-to-annual</guid>
		</item>
				<item>
			<title>Best Practices Regarding Data Types and Values</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/454689/best-practices-regarding-data-types-and-values</link>
			<pubDate>Wed, 15 May 2013 18:32:49 +0000</pubDate>
			<description>Hi All, I sort of want to get a &quot;best practices&quot; perspective regarding numeric values. First, I'll give my scenario: In my SSIS package, a CSV file is used for data extraction. Once extracted, a staging table is loaded with all the values from the CSV. One column, called &quot;IPI_Value&quot; ...</description>
			<content:encoded><![CDATA[ <p>Hi All,</p>

<p>I sort of want to get a "best practices" perspective regarding numeric values.  First, I'll give my scenario:<br />
In my SSIS package, a CSV file is used for data extraction. Once extracted, a staging table is loaded with all the values from the CSV. One column, called "IPI_Value" is a numeric (18,2) type.  However, some of the data being loaded contain the value 'x' if there is no numeric value in the dataset.  Obviously I can't store 'x' in a numeric field within the database so I came up with:</p>

<pre><code class="language-sql">update a
set a.IPI_Value = REPLACE(a.IPI_Value,'x','0')
from dbo.tblIPIStaging a
where a.IPI_Value='x'
</code></pre>

<p>The question I have is whether or not the value being replacing the 'x' should be a '0' or NULL.  A 0, in my opinion can be misleading when analysing the data afterwards as the 'x' represents a non-value for a given timeframe.  So what is the best practice then, replacing with 0 or a NULL?  Or does it not really matter.</p>

<p>I know at query time the query can rule out either values with 0s or NULLs so....</p>

<p>Anyways, the people of this forum always give me the best advice so I anticipate your suggestions.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>Stuugie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/454689/best-practices-regarding-data-types-and-values</guid>
		</item>
				<item>
			<title>Entering 40000 rows in sql server through loop</title>
			<link>http://www.daniweb.com/web-development/databases/threads/454606/entering-40000-rows-in-sql-server-through-loop</link>
			<pubDate>Tue, 14 May 2013 17:24:52 +0000</pubDate>
			<description>I have to make a database system that is purely on SQL Server. It's about a diagnostic lab. It should contain at least 40,000 distinct patient records. I have a table named &quot;Patient&quot; which contains an auto-generated ID, Name, DOB, Age and Phone number. Our teacher provided us with a ...</description>
			<content:encoded><![CDATA[ <p>I have to make a database system that is purely on SQL Server. It's about a diagnostic lab. It should contain at least 40,000 distinct patient records. I have a table named "Patient" which contains an auto-generated ID, Name, DOB, Age and Phone number. Our teacher provided us with a dummy stored procedure which contained 2 temporary tables that has 200 names each and in the end he makes a Cartesian product which is supposed to give 40,000 distinct rows. I have used the same dummy stored procedure and modified it according to our table. But the rows inserted are only 1260 every time. Each time we run the query it does not give us more than 1260 records. I have added a part of temporary name tables and the stored procedure.</p>

<pre><code class="language-sql">Declare  @tFirstNames Table( FirstName Varchar(50) Not Null )
Declare @tLastNames Table ( LastName Varchar(50) Not Null )
Declare @tNames Table ( Id Int Identity Not Null, Name Varchar(50) Not Null)
Insert Into @tFirstNames (FirstName)
    Select 'Julianne' Union All Select 'Sharyl' Union All Select 'Yoshie'
    Union All Select 'Germaine' Union All Select 'Ja' Union All
    Select 'Kandis' Select 'Hannelore' Union All Select 'Laquanda' Union All
    Select 'Clayton' Union All Select 'Ollie' Union All
    Select 'Rosa' Union All Select 'Deloras' Union All
    Select 'April' Union All Select 'Garrett' Union All
    Select 'Mariette' Union All Select 'Carline' Union All


Insert Into @tLastNames (LastName)
    Select 'Brown' Union All Select 'Chrichton' Union All Select 'Bush'
    Union All Select 'Clinton' Union All Select 'Blair'
    Union All Select 'Wayne' Union All Select 'Hanks'
    Union All Select 'Cruise' Union All Select 'Campbell'
    Union All Select 'Turow' Union All Select 'Tracey' 
    Union All Select 'Arnold' Union All Select 'Derick' 
    Union All Select 'Nathanael' Union All Select 'Buddy' 

Insert Into @tNames
Select  FirstName + ' ' + LastName
    From @tFirstNames, @tLastNames

Declare @iIndex Integer
Declare @iPatientTotalRecords Integer
Declare @vcName Varchar(50)
Declare @iAge Integer
--Set @iIndex = 1
Select @iPatientTotalRecords = Max(Id), @iIndex = Min(Id) From @tNames

While @iIndex &lt;= @iPatientTotalRecords
Begin

    Select @vcName = Name From @tNames Where Id = @iIndex
    Set @iAge = Cast( Rand() * 70 As Integer ) + 10
    Insert into Patient values
        (@vcName, @iAge,
            Case Cast( Rand() * 3  As Integer)
            When 0 Then 'Male'
            When 1 Then 'Female'
            Else 'Female'
            End,
            Cast( Rand() * 8888889 As Integer ) + 1111111, DateAdd ( year, -@iAge, GetDate()))

    Set @iIndex = @iIndex + 1
End
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>moomal.razak</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/454606/entering-40000-rows-in-sql-server-through-loop</guid>
		</item>
				<item>
			<title>SUM() all number fields individually</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/454414/sum-all-number-fields-individually</link>
			<pubDate>Sat, 11 May 2013 15:00:26 +0000</pubDate>
			<description>I'm trying to sum all numeric fields individually. I won't always know the field names, otherwise I could manually construct the query `SELECT SUM(Field1) as Field1, SUM(Field2) as Field2...etc FROM myTable` Is there a way to construct this on the fly in mysql? I'm thinking there's probably a way to ...</description>
			<content:encoded><![CDATA[ <p>I'm trying to sum all numeric fields individually. I won't always know the field names, otherwise I could manually construct the query <code>SELECT SUM(Field1) as Field1, SUM(Field2) as Field2...etc FROM myTable</code>  Is there a way to construct this on the fly in mysql? I'm thinking there's probably a way to incorporate  <code>SELECT COLUMN_NAME FROM information_schema WHERE TABLE_NAME=myTableName AND DATA_TYPE IN('tinyint','decimal')</code>, but I'm not sure how. Thanks!</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>grant.baker</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/454414/sum-all-number-fields-individually</guid>
		</item>
				<item>
			<title>Lock and Unlock SQL Data Table</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/454125/lock-and-unlock-sql-data-table</link>
			<pubDate>Tue, 07 May 2013 22:47:09 +0000</pubDate>
			<description>Hi Group! I've created a stored SQL procedure that will need to be modified to lock the table, run the commands and then unlock the table. I need to do this because I want any other users/programs that will need access to &quot;wait in line&quot; until the procedure is finished. ...</description>
			<content:encoded><![CDATA[ <p>Hi Group!</p>

<p>I've created a stored SQL procedure that will need to be modified to lock the table, run the commands and then unlock the table.  I need to do this because I want any other users/programs that will need access to "wait in line" until the procedure is finished.  It's short a very short procedure.  So in essence, I want to</p>

<pre><code class="language-vb">'Lock the table
'run the commands here
SELECT @today = GETDATE(), @ordno = OrderNo FROM ORDRNUMBERREC
SELECT MAX(OrderNumberID), @ordno FROM ORDRNUMBERREC
SELECT @ordno1 = @ordno + 1
INSERT INTO ORDRNUMBERREC
(OrderNo, UserID, CreateDate)
VALUES(@ordno1, 'system', @today)
'now Unlock the table
</code></pre>

<p>I've been reading on this and find the command, TABLOCKX, and this may be what I'm looking for.</p>

<p>My questions are:</p>

<p>1) where is this command inserted (within the SQL procedure or within the VB code)?<br />
2) is there a "unlock" version of this or does the table unlock when the routine is exited?</p>

<p>In advance, thanks for the help.</p>

<p>Don</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>doncwilson_1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/454125/lock-and-unlock-sql-data-table</guid>
		</item>
				<item>
			<title>Read DB Table and Place All The Read Values into a String</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/454124/read-db-table-and-place-all-the-read-values-into-a-string</link>
			<pubDate>Tue, 07 May 2013 22:12:31 +0000</pubDate>
			<description>Hi All, I'm working on filling a user variable called &quot;EmailString&quot; via a db connection with SSIS. I've created a script task to do this (the only way I can see how) and in it I have the following code: Public Sub Main() ' ' Add your code here ' ...</description>
			<content:encoded><![CDATA[ <p>Hi All,</p>

<p>I'm working on filling a user variable called "EmailString" via a db connection with SSIS.  I've created a script task to do this (the only way I can see how) and in it I have the following code:</p>

<pre><code class="language-sql">Public Sub Main()
        '
        ' Add your code here
        '
        Dim myPackageID As String = Dts.Variables("System::PackageID").Value.ToString()
        Dim myVal As String = String.Empty
        Dim cmdString As String = "Select Email from dbo.tblInternal_Email_List where Active = @1"

        Try
            Dim myCon As SqlClient.SqlConnection
            myCon = DirectCast(Dts.Connections(0).AcquireConnection(Nothing), SqlClient.SqlConnection)
            myCon = New SqlClient.SqlConnection(myCon.ConnectionString)
            myCon.Open()
            Dim cmd = New SqlClient.SqlCommand()
            cmd.CommandText = cmdString
            Dim parm As New SqlClient.SqlParameter("@PACKAGEID", SqlDbType.UniqueIdentifier)
            parm.Value = New Guid(myPackageID)
            cmd.Parameters.Add(parm)
            parm = New SqlClient.SqlParameter("@SETTINGID", SqlDbType.NVarChar)
            parm.Value = "EmailString"
            cmd.Parameters.Add(parm)
            cmd.Connection = myCon
            cmd.CommandText = cmdString

            Dim reader As SqlClient.SqlDataReader = cmd.ExecuteReader
            Do While (reader.Read())
                myVal = myVal &amp; reader("value").ToString &amp; "; "
            Loop
            Dts.Variables("User::EmailString").Value = myVal
            reader.Close()
            myCon.Close()
            myCon.Dispose()

        Catch ex As Exception
            Dts.TaskResult = ScriptResults.Failure
            Throw
        End Try

        Dts.TaskResult = ScriptResults.Success
    End Sub
</code></pre>

<p>This code has been adapted from a book I have but it throws the following error:</p>

<blockquote>
  <p>Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.</p>
</blockquote>

<p>Can anyone tell me why based on what I have provided?</p>

<p>What I want is to read the Email column from the db table and then put the email addresses into the EmailString.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>Stuugie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/454124/read-db-table-and-place-all-the-read-values-into-a-string</guid>
		</item>
				<item>
			<title>Update from a select query</title>
			<link>http://www.daniweb.com/web-development/databases/threads/454021/update-from-a-select-query</link>
			<pubDate>Mon, 06 May 2013 13:41:13 +0000</pubDate>
			<description>I want to update a colume using results from an select query but its not working :( my code: UPDATE goods SET goods.wagons_needed = (SELECT (goods.QUANTITY * WEIGHT) / max_payload as wneed FROM GOODS INNER JOIN wagon_type ON goods.wagon_type_id = wagon_type.wagon_type_id order by goods.goods_id) where goods.goods_id = goods.goods_id; Thanks for ...</description>
			<content:encoded><![CDATA[ <p>I want to update a colume using results from an select query but its not working :( my code:</p>

<pre><code class="language-sql">UPDATE goods
SET goods.wagons_needed = (SELECT (goods.QUANTITY * WEIGHT) / max_payload as wneed
FROM GOODS INNER JOIN wagon_type 
ON goods.wagon_type_id = wagon_type.wagon_type_id
order by goods.goods_id)
where goods.goods_id = goods.goods_id;
</code></pre>

<p>Thanks for any help.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>kamil.metkowski</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/454021/update-from-a-select-query</guid>
		</item>
				<item>
			<title>Auto generate sequential foreign key when inserting record</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/453980/auto-generate-sequential-foreign-key-when-inserting-record</link>
			<pubDate>Mon, 06 May 2013 05:52:10 +0000</pubDate>
			<description>I have a table called `DUTY` (columns: `dutyid, dutyname, staffid`) and a table called `STAFF` (columns: `staffid, staffname`) In order to be fair, each of the staff will be auto assigned to each duty entry (record). So what should I do whenever I would like to insert a duty entry, ...</description>
			<content:encoded><![CDATA[ <p>I have a table called <code>DUTY</code> (columns: <code>dutyid, dutyname, staffid</code>) and a table called <code>STAFF</code> (columns: <code>staffid, staffname</code>)</p>

<p>In order to be fair, each of the staff will be auto assigned to each duty entry (record). So what should I do whenever I would like to insert a duty entry, it will auto assign the <code>staffid</code> (sequential) for it.</p>

<p>Example</p>

<ul><li>staffid : 1 staffname: Jack</li>
<li>staffid : 2 staffname: Mary</li>
</ul>

<p>So when I insert a new entry (first entry) for duty, it will auto insert <code>staffid = 1</code> for duty table. For second entry, <code>staffid</code> will be 2.</p>

<p>And for the following entry, it will keep looping the <code>staffid</code> sequentially.</p>

<p>Desired answer:</p>

<pre><code class="language-sql">dutyid   dutyname   staffid 
  1      cleaning     1 
  2      cleaning     2 
  3      cleaning     1 
  4      cleaning     2 
  5      cleaning     1 
  6      cleaning     2 
  7      cleaning     3       new staff
  8      cleaning     1 
  9      cleaning     2 
 10      cleaning     3 
</code></pre>

<p>Can anyone show and explain to me what I should do in my stored procedure...<br />
Thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>taekiewzz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/453980/auto-generate-sequential-foreign-key-when-inserting-record</guid>
		</item>
				<item>
			<title>Removing 2 records at a time</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/453834/removing-2-records-at-a-time</link>
			<pubDate>Fri, 03 May 2013 10:29:00 +0000</pubDate>
			<description>Hi, I have a very specific issue that I'm unable to work out a solution to. It's related to WordPress, but that's for context and isn't otherwise relevant. I have a table named wp_options. It's used to store various option information using 2 fields - option_name and option_value. These are, ...</description>
			<content:encoded><![CDATA[ <p>Hi,</p>

<p>I have a very specific issue that I'm unable to work out a solution to. It's related to WordPress, but that's for context and isn't otherwise relevant.</p>

<p>I have a table named wp_options. It's used to store various option information using 2 fields - option_name and option_value. These are, as they suggest, a unique name for the option and a value for that option.</p>

<p>This table is also used to store "transients" - temporary option values. These are stored as 2 records:</p>

<p>Record 1 has the name format of _transient_timeout_xxx, where xxx is the unique name. The value contains an expiry time.</p>

<p>Record 2 has the name format of _transient_xxx, where xxx is the unique name used as per record 1. The value contains the temporary option value.</p>

<p>What I want to do is to remove any transient records which have expired. Basically, hunt down any "record 1's" which have expired and to delete that and the matching record 2. But I can't work out how to do this withing a single MySQL statement. Is anybody more capable able to think of something?</p>

<p>Any help will be gratefully appreciated.<br />
David.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>dartiss</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/453834/removing-2-records-at-a-time</guid>
		</item>
				<item>
			<title>Linking table entries to a foreign key</title>
			<link>http://www.daniweb.com/web-development/databases/threads/453592/linking-table-entries-to-a-foreign-key</link>
			<pubDate>Mon, 29 Apr 2013 21:17:39 +0000</pubDate>
			<description>I have the following tables **tbl_cat** -- id(pk), category (PRODUCT CATEGORIES) **tbl_subcat** - id, catid, subcat (catid is a foregin key referencing id in **tbl_cat** ) - SUB CATEGORIES I want to prepopulate my tables with categories and sub-categories of products. it's quite straightforward to insert categories in **tbl_cat** but ...</description>
			<content:encoded><![CDATA[ <p>I have the following tables<br /><strong>tbl_cat</strong> -- id(pk), category  (PRODUCT CATEGORIES)<br /><strong>tbl_subcat</strong> - id, catid, subcat (catid is a foregin key referencing id in <strong>tbl_cat</strong> ) - SUB CATEGORIES<br />
I want to prepopulate my tables with categories and sub-categories of products. it's quite straightforward to insert categories in <strong>tbl_cat</strong> but each entry in <strong>tbl_subcat</strong> must reference a category. For example if i have a category called <strong>Acessories</strong>, then all items in the subcategory like wristbands, necklace and rings should all have thesame catid that references <strong>Acessories</strong> in the <strong>tbl_cat</strong> table.<br />
How can i implement this. Thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>dhani09</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/453592/linking-table-entries-to-a-foreign-key</guid>
		</item>
				<item>
			<title>nvarchar to numeric</title>
			<link>http://www.daniweb.com/web-development/databases/threads/453552/nvarchar-to-numeric</link>
			<pubDate>Mon, 29 Apr 2013 09:14:16 +0000</pubDate>
			<description>I am using sqlserver 2012. i want to convert nvarchar value from a table in to an integer. How can i do it? i am using it in a stored procedure. and nvarchar value only contains numbers. What i want to do is to multiple that nvarchar value and assign ...</description>
			<content:encoded><![CDATA[ <p>I am using sqlserver 2012. i want to convert nvarchar value from a table in to an integer. How can i do it? i am using it in a stored procedure. and nvarchar value only contains numbers.<br />
 What i want to do is to multiple that nvarchar value and assign it to int variable.. When i tried it Following error comes</p>

<pre><code class="language-sql">Select @temp = @nvarcharvalue * 2
</code></pre>

<p>I also tried.</p>

<pre><code class="language-sql"> Select @temp = CAST(@nvarcharvalue as int)* 2
</code></pre>

<p>Following error is shown.</p>

<p>The conversion of the nvarchar value '20130429044221' overflowed an int column.</p>

<p>How can it be done?<br />
Thanks in advance</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>jrosh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/453552/nvarchar-to-numeric</guid>
		</item>
				<item>
			<title>How to selectively get rows that match criteria</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/453471/how-to-selectively-get-rows-that-match-criteria</link>
			<pubDate>Sat, 27 Apr 2013 22:46:01 +0000</pubDate>
			<description>I have a table with several columns, the two relevant columns for what I need to do are invoiceNumber and stockNumber. The scenario here is that it's a table of invoice information, so each invoice can have and will most likely have multiple rows in the table which represent each ...</description>
			<content:encoded><![CDATA[ <p>I have a table with several columns, the two relevant columns for what I need to do are invoiceNumber and stockNumber.  The scenario here is that it's a table of invoice information, so each invoice can have and will most likely have multiple rows in the table which represent each line item sold on the invoice.<br />
I need to pick out only the invoices that have a stockNumber that begins with the letters "CC".  The "CC" items are an extended warranty that was sold.<br />
So in other words I need to get all the rows for invoices in the table that have a "CC" stockNumber so that I can do some further manipulation of those invoices.<br />
An example of the rows for an invoice that has a "CC" stockNumber in one of the rows might be like this:</p>

<pre><code class="language-sql">    invoiceNumber   invoiceDate customerNumber  stockNumber soldQty soldPrice
    -------------   ----------- --------------  ----------- ------- ---------
    489670          2013-04-11  25116           LR76003-34  1       899.99
    489670          2013-04-11  25116           LR76003-08  1       0.00
    489670          2013-04-11  25116           CCCOMBO     1       99.99
</code></pre>

<p>I would need to get all those rows.</p>

<p>An example of the rows for an invoice that does not have a "CC" stockNumber in any of the rows might be like this:</p>

<pre><code class="language-sql">invoiceNumber   invoiceDate customerNumber  stockNumber soldQty soldPrice
-------------   ----------- --------------  ----------- ------- ---------
4934170         2013-04-11  30738           OCT477-8    1       359.99
4934170         2013-04-11  30738           OCT477-6    1       116.99
</code></pre>

<p>I would need to completely skip these rows since none of the rows have a "CC" stockNumber.</p>

<p>I hope I'm making sense with this, thanks for any suggestions.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>spowel4</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/453471/how-to-selectively-get-rows-that-match-criteria</guid>
		</item>
				<item>
			<title>class diagram</title>
			<link>http://www.daniweb.com/web-development/databases/threads/453443/class-diagram</link>
			<pubDate>Sat, 27 Apr 2013 09:45:21 +0000</pubDate>
			<description>what is the meaning of 0.* and 1.* relationship in class diagrams?</description>
			<content:encoded><![CDATA[ <p>what is the meaning of 0.* and 1.* relationship in class diagrams?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>tubzz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/453443/class-diagram</guid>
		</item>
				<item>
			<title>SQL SERVER – Removing Leading Zeros From Column in Table</title>
			<link>http://www.daniweb.com/web-development/databases/threads/453436/sql-server-removing-leading-zeros-from-column-in-table</link>
			<pubDate>Sat, 27 Apr 2013 08:57:08 +0000</pubDate>
			<description>Hi iam using sql server 2008 to deal with my DB, i have a column with 'int' data type when i insert number inside that column like &quot;0025648&quot; it return it to me &quot;25648&quot; without zeros why ? and how to solve this problem ? Best Regard IT_Techno</description>
			<content:encoded><![CDATA[ <p>Hi</p>

<p>iam using sql server 2008 to deal with my DB, i have a column with 'int' data type when i insert number inside that column like "0025648" it return it to me "25648" without zeros why ? and how to solve this problem ?</p>

<p>Best Regard<br />
IT_Techno</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>IT_Techno</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/453436/sql-server-removing-leading-zeros-from-column-in-table</guid>
		</item>
				<item>
			<title>Using SQL CURDATE() Interval</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/453344/using-sql-curdate-interval</link>
			<pubDate>Thu, 25 Apr 2013 22:19:29 +0000</pubDate>
			<description>Hi all - use the curdate() or current date to look at newly added awards in the last 3 months The SQL table used to store the created date when an award was added is **tbl_net_centre.reg_date** and keeps throwing up an error on the &lt;= If anyone can advise the ...</description>
			<content:encoded><![CDATA[ <p>Hi all - use the curdate() or current date to look at newly added awards in the last 3 months<br />
The SQL table used to store the created date when an award was added is <strong>tbl_net_centre.reg_date</strong> and keeps throwing up an error on the &lt;= If anyone can advise the correct syntax for this.</p>

<pre><code class="language-sql">-- New Networks by date less than 3 months--
select 
    tbl_centre.centre_id,
    tbl_centre.centre_no,
    tbl_centre.centre_name,
    tbl_region.region,
    tbl_net.network_code,
    tbl_centre.reg_date,
    tbl_net_centre.reg_date,
    count(tbl_centre.reg_date) as Nunmber_of_New_networks 

FROM
    tbl_centre
     LEFT JOIN
    tbl_net_centre ON tbl_centre.reg_date = tbl_net_centre.reg_date
        LEFT JOIN
    tbl_net_centre ON tbl_centre.centre_id = tbl_net_centre.centre_id
        LEFT JOIN
    tbl_net ON tbl_net_centre.ntwrk_cd = tbl_net.network_code
        LEFT JOIN
    tbl_region ON tbl_centre.region_code = tbl_region.region_ID
WHERE
    tbl_centre.reg_status = 'R'
        AND tbl_net_centre.net_reg_stts in ('R' , 'P')
        AND tbl_region.region_ID = '3'
       AND 'tbl_net_centre.reg-date' &lt;=(CURDATE(), INTERVAL 3 MONTH)
group by tbl_centre.centre_id
having Nunmber_of_New_networks =1 AND network_code='E'
limit 1000;
</code></pre>

<p>Thanks in advance</p>

<p>D</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>davidjennings</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/453344/using-sql-curdate-interval</guid>
		</item>
				<item>
			<title>I need help with a query</title>
			<link>http://www.daniweb.com/web-development/databases/threads/453307/i-need-help-with-a-query</link>
			<pubDate>Thu, 25 Apr 2013 12:05:47 +0000</pubDate>
			<description>Hey there, I need help with writing a query so I figured I'd ask here. Let me thank you in advance for your answer. I need to see how often a value inside a certain column appears in a table. Say for example I have a table Person, that has ...</description>
			<content:encoded><![CDATA[ <p>Hey there,<br />
I need help with writing a query so I figured I'd ask here. Let me thank you in advance for your answer.</p>

<p>I need to see how often a value inside a certain column appears in a table. Say for example I have a table Person, that has a field name.</p>

<p>I want to know top five most frequently occuring names, along with the number indicating how often each appears.</p>

<p>Thank you.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>bibiki</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/453307/i-need-help-with-a-query</guid>
		</item>
				<item>
			<title>Query resolve</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/453273/query-resolve</link>
			<pubDate>Thu, 25 Apr 2013 05:37:12 +0000</pubDate>
			<description>Hi all I have an sql output query problem I am trying to resolve. The problem is that I have centres that offer Awards and quals and some centres only offer awards or quals only. What I need to process is the centres that offer both awards and quals. tbl.net.qualification ...</description>
			<content:encoded><![CDATA[ <p>Hi all I have an sql output query problem I am trying to resolve.</p>

<p>The problem is that I have centres that offer Awards and quals and some centres only offer awards or quals only.</p>

<p>What I need to process is the centres that offer both awards and quals.</p>

<p>tbl.net.qualification contains the data a qual = 0 and awards =1 so in this data output only need pull out centres that have both quals and awards 0 and 1.</p>

<p>Thanks in advance</p>

<pre><code class="language-sql"> select 
        tbl_centre.centre_id,
                    tbl_centre.centre_no,
                    tbl_centre.centre_name,
                    tbl_region.region,
                    tbl_net.qualification,
                    sum(tbl_net.qualification) = count(tbl_net.qualification) as only_does_qualifications,
                    sum(tbl_net.qualification) = 0 as only_does_awards

    from
        tbl_centre

    left join
        tbl_net_centre ON tbl_centre.centre_id = tbl_net_centre.centre_id

    left join
        tbl_net ON tbl_net_centre.ntwrk_cd = tbl_net.network_code

   left join
                    tbl_region ON tbl_centre.region_code = tbl_region.region_ID

    where
                    tbl_centre.reg_status = 'R'
    and
                    tbl_net_centre.net_reg_stts in ('R','P')
    and
                    tbl_region.region_ID ='3'


    group by tbl_centre.centre_id

    having only_does_qualifications - only_does_awards &lt;&gt;0
    limit 1000;
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>davidjennings</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/453273/query-resolve</guid>
		</item>
				<item>
			<title>will MySQL community server 5.6 run on winXP SP2 ?</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/453205/will-mysql-community-server-5.6-run-on-winxp-sp2-</link>
			<pubDate>Wed, 24 Apr 2013 12:33:34 +0000</pubDate>
			<description>i basically need mySQL for learning JDBC connections. will be thankful to any information regarding this matter. didnt find anything concrete on the net...</description>
			<content:encoded><![CDATA[ <p>i basically need mySQL for learning JDBC connections. will be thankful to any information regarding this matter. didnt find anything concrete on the net...</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>somjit{}</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/453205/will-mysql-community-server-5.6-run-on-winxp-sp2-</guid>
		</item>
				<item>
			<title>Query with SQL</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/453121/query-with-sql</link>
			<pubDate>Tue, 23 Apr 2013 13:14:14 +0000</pubDate>
			<description>I am running analyses on a quiz and am trying to manipulate querys in order to produce bar charts. I am trying to display a graph which shows the percentages of candidates passing a particular quiz. The query I am trying to run is as follows: SELECT QuizName, (100*(COUNT(PassFail))/(COUNT(XXXXXX))) AS ...</description>
			<content:encoded><![CDATA[ <p>I am running analyses on a quiz and am trying to manipulate querys in order to produce bar charts. I am trying to display a graph which shows the percentages of candidates passing a particular quiz. The query I am trying to run is as follows:</p>

<pre><code class="language-sql">SELECT QuizName, (100*(COUNT(PassFail))/(COUNT(XXXXXX))) AS 'Total'
FROM Resultsets
WHERE PassFail ='PASS'
GROUP BY QuizName
</code></pre>

<p>Where XXXXX has been a number of things listed below, all which have failed.</p>

<p>1) I have tried to use the line (100*(COUNT(PassFail),(WHERE PassFail= PASS)) / (COUNT (PassFail)))<br />
2) I have also tried creating a routine which counts the number of times a Quiz has been used and than using CALL in the place of COUNT(XXXX), this didnt work.</p>

<p>I am not sure what to do? The quizzes have been attempted a different number of times so I cant just insert a number. Any help would be greatly appreciated!! Plus if i have emitted any necessary information please let me know and I will include it.</p>

<p>Many thanks,</p>

<p>Will</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>wvoke9</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/453121/query-with-sql</guid>
		</item>
				<item>
			<title>my table not insert it in db</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/453110/my-table-not-insert-it-in-db</link>
			<pubDate>Tue, 23 Apr 2013 11:40:59 +0000</pubDate>
			<description>hi everyone i have problem in my code i'm create datbase and table by write in php code but in my phpmyadmin it insert the database only the table dose noe exit here my code &lt;?php $connect = mysql_connect(&quot;127.0.0.1&quot;,&quot;root&quot;,&quot;&quot;); $db = mysql_select_db(&quot;login&quot;); mysql_query(&quot;CREATE DATABASE login&quot;); mysql_query(&quot;CREATE TABLE users ( id ...</description>
			<content:encoded><![CDATA[ <p>hi everyone i have problem in my code i'm create datbase and table by write in php code but in my phpmyadmin it insert the database only the table dose noe exit here my code</p>

<pre><code class="language-sql">&lt;?php

$connect = mysql_connect("127.0.0.1","root","");
$db = mysql_select_db("login");

mysql_query("CREATE DATABASE login");

mysql_query("CREATE TABLE users

(
id int,
fullname varchar(30),
username varchar(30),
password vaechar(32)
)");



echo "Data Inserted!";

?&gt; 
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>aisha.edris1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/453110/my-table-not-insert-it-in-db</guid>
		</item>
				<item>
			<title>sql</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/453102/sql</link>
			<pubDate>Tue, 23 Apr 2013 10:26:20 +0000</pubDate>
			<description>how to round of the value after finding the avg in sql</description>
			<content:encoded><![CDATA[ <p>how to round of  the  value after finding the avg in sql</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>Deeksh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/453102/sql</guid>
		</item>
				<item>
			<title>Trouble restoring database backed with mysqldump</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452770/trouble-restoring-database-backed-with-mysqldump</link>
			<pubDate>Thu, 18 Apr 2013 14:43:17 +0000</pubDate>
			<description>Hi friends! I have some trouble restoring a mysql database that I backed up with mysqldump. I have been trying to do this from a command prompt (Windows) This is my code: mysql -u root -pPassword databasename &lt; C:\Backup\databaseNameToBeRestored.sql With this, I get the message that &quot;mysql&quot; is not recognized ...</description>
			<content:encoded><![CDATA[ <p>Hi friends!<br />
I have some trouble restoring a mysql database that I backed up with mysqldump. I have been trying to do this from a command prompt (Windows)</p>

<p>This is my code:</p>

<pre><code class="language-sql">mysql -u root -pPassword databasename &lt; C:\Backup\databaseNameToBeRestored.sql
</code></pre>

<p>With this, I get the message that "mysql" is not recognized as internal or external or external command, operable program or batch file.</p>

<p>I added "" to get "mysql -u root -pPassword databasename &lt; C:\Backup\databaseNameToBeRestored.sql" But to this I get error message "The filename, directory name, or volume lable syntax is incorrect"</p>

<p>This man <a href="http://www.daniweb.com/web-development/databases/mysql/threads/311270/restoring-mysql-database-using-commandline" rel="nofollow">here </a>said the code I tried worked for him.</p>

<p>Any help please? (and if you don't mind, I would appreciate if somebody could told me why changing &gt; to &lt; in the mysqldump command does not work 100% in restoring the backed database)</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>savedlema</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452770/trouble-restoring-database-backed-with-mysqldump</guid>
		</item>
				<item>
			<title>Procedure</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452730/procedure</link>
			<pubDate>Thu, 18 Apr 2013 01:38:12 +0000</pubDate>
			<description>Hi all I'm trying to write a Procedure to subtract days from a data but Ignoring weekends. This is what I have so far but I have a Syntax error Unexpected END, Expecting `;` I have put a ; after the last END but still get the same error. DELIMITER ...</description>
			<content:encoded><![CDATA[ <p>Hi all I'm trying to write a Procedure to subtract days from a data but Ignoring weekends.<br />
This is what I have so far but I have a Syntax error Unexpected END, Expecting <code>;</code><br />
I have put a ; after the last END but still get the same error.</p>

<pre><code class="language-sql">DELIMITER $$ 
CREATE PROCEDURE `production`.`new_procedure` (in fDate Date, fVal int) 
BEGIN 
Declare x int default 1; 
Declare NewDate Date; 
WHILE x &lt;= fVal DO 
set NewDate=Date_SUB(fDate,interval x Day); 
SELECT 
CASE DAYNAME(NewDate) 
WHEN `Saturday` THEN fVal=fVal+1 
WHEN `Sunday` THEN fVal=fVal+1 
Else x=x+1 
END 
End 
END$$
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>VIPER5646</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452730/procedure</guid>
		</item>
				<item>
			<title>SELECT Columns FROM different Tables using WHERE clause</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/452728/select-columns-from-different-tables-using-where-clause</link>
			<pubDate>Wed, 17 Apr 2013 23:24:47 +0000</pubDate>
			<description>Hi to all, As a newbie, I am not able to have the following columns into a datagrid. (see database diagram attached) (I don't want to select ID columns because users may not be able to identify the students). I don't master JOINS . Infact I want to select all ...</description>
			<content:encoded><![CDATA[ <p>Hi to all,<br />
As a newbie, I am not able to have the following columns into a datagrid. (see database diagram attached)<br />
(I don't want to select ID columns because users may not be able to identify the students). I don't master JOINS .</p>

<p>Infact I want to select all students from tbl_scores who are in a class(level) called F1A and offer the subject Maths</p>

<p><strong><em>SELECT SubjectName, ClassName, StudentName, Seq1<br />
FROM Tbl_Scores --etc<br />
WHERE ClassName='F1A' AND Subjectname='Maths'</em></strong></p>

<p>There should be exactly 10 records selected.<br />
But I get Multiple similar records<br />
Can some help by refering to diagram?<br />
thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>gbhs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/452728/select-columns-from-different-tables-using-where-clause</guid>
		</item>
				<item>
			<title>Finding the last row number in a data table</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/452658/finding-the-last-row-number-in-a-data-table</link>
			<pubDate>Wed, 17 Apr 2013 02:55:28 +0000</pubDate>
			<description>Hi group, I'm still learning Visual Basic and SQL. Please overlook my inabilities. I'm writing a module that is meant to write a small amount of data to a database. I've named these fields 'PrinterID', 'PrinterName', 'PrinterNumber', 'PrinterLocation' and 'PrinterAddress'. The user will eventually have 30 or 40 records to ...</description>
			<content:encoded><![CDATA[ <p>Hi group,</p>

<p>I'm still learning Visual Basic and SQL.  Please overlook my inabilities.</p>

<p>I'm writing a module that is meant to write a small amount of data to a database.  I've named these fields 'PrinterID', 'PrinterName', 'PrinterNumber', 'PrinterLocation' and 'PrinterAddress'.  The user will eventually have 30 or 40 records to add to this file.</p>

<p>My questions are: when writing to the file, how do I number the rows (this will be the PrinterID)?  As the user adds to this, how do I find the last row number so that I can assign the next row value?  And lastly, do these rows begin with '0' or '1'?  I ask, because I assume '0'.  But I'd rather it be 1!</p>

<p>In advance, thanks for the help.</p>

<p>Don</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>doncwilson_1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/452658/finding-the-last-row-number-in-a-data-table</guid>
		</item>
				<item>
			<title>phpmyadmin</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452603/phpmyadmin</link>
			<pubDate>Tue, 16 Apr 2013 11:05:31 +0000</pubDate>
			<description>Any ideas please on where should I look for help with making a site (lecaff.fr) that includes phpmyadmin, work on the remote server. It works fine on the testing server and through various browsers using Dreamweaver cs6 and phpMyAdmin 3.3.9. It also responds when I comment out the php script.</description>
			<content:encoded><![CDATA[ <p>Any ideas please on where should I look for help with making a site (lecaff.fr) that includes phpmyadmin, work on the remote server. It works fine on the testing server and through various browsers using Dreamweaver cs6 and phpMyAdmin 3.3.9. It also responds when I comment out the php script.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>keeleyb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452603/phpmyadmin</guid>
		</item>
				<item>
			<title>simple query need urgent help</title>
			<link>http://www.daniweb.com/web-development/databases/threads/452481/simple-query-need-urgent-help</link>
			<pubDate>Mon, 15 Apr 2013 02:35:01 +0000</pubDate>
			<description> here is my table in database: name qty unitcost totalcost A 1 10 10 A 3 10 30 B 2 20 40 B 1 20 20 here is what i want to view to user: name qty unitcost totalcost A 4 10 40 B 3 20 60</description>
			<content:encoded><![CDATA[ <pre><code class="language-sql">here is my table in database:

name     qty     unitcost     totalcost
A        1       10           10
A        3       10           30
B        2       20           40
B        1       20           20

here is what i want to view to user:

name     qty     unitcost     totalcost
A        4       10           40
B        3       20           60
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>GeoEqual</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/452481/simple-query-need-urgent-help</guid>
		</item>
				<item>
			<title>recreate my oracle database to sql server</title>
			<link>http://www.daniweb.com/web-development/databases/threads/452307/recreate-my-oracle-database-to-sql-server</link>
			<pubDate>Fri, 12 Apr 2013 16:38:45 +0000</pubDate>
			<description>I am tring to recreate my oracle database -&gt; sql server 2008. I never used sql server before, so I am using sql server management studio. I could create tables and views. The views I created using sql server management studio GUI has data in it. Now, I tried to ...</description>
			<content:encoded><![CDATA[ <p>I am tring to recreate my oracle database -&gt; sql server 2008. I never used sql server before, so I am using sql server management studio. I could create tables and views. The views I created using sql server management studio GUI has data in it.<br />
Now, I tried to use a script to create a view. The view was created but no data in it... I am sure that I'm missing some basic things.<br />
Anybody please tell me what am I missing?</p>

<pre><code class="language-sql">USE[DB101] 
GO
CREATE VIEW TEST 
AS
SELECT     dbo.EMPLOYEE.EMPID, dbo.EMPLOYEE.LASTNAME, dbo.EMPLOYEE.MIDDLE, dbo.EMPLOYEE.FIRSTNAME, dbo.EMPLOYEE.STREET, 
                      dbo.EMPLOYEE.CITY, dbo.EMPLOYEE.STATE, dbo.EMPLOYEE.ZIP, dbo.EMPLOYEE.TERMS, dbo.EMPLOYEE.RATE, dbo.EMPLOYEE.QTY, 
                      dbo.EMPLOYEE.VAC_RATE, dbo.EMPLOYEE.QTY_PAID_VAC, dbo.EMPLOYEE.QTY_OVER_TIME, dbo.EMPLOYEE.[GROSS-PAY], 
                      dbo.EMPLOYEE.IDTAX, dbo.TAX.TAX_TOTAL, dbo.EMPLOYEE.OT_RATE, dbo.EMPLOYEE.NET_PAY
FROM         dbo.EMPLOYEE INNER JOIN
                      dbo.TAX ON dbo.EMPLOYEE.IDTAX = dbo.TAX.IDTAX
GO
</code></pre>

<p>Regards,</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>doraemon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/452307/recreate-my-oracle-database-to-sql-server</guid>
		</item>
				<item>
			<title>Sql Statement Issues</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452297/sql-statement-issues</link>
			<pubDate>Fri, 12 Apr 2013 14:11:08 +0000</pubDate>
			<description>I'm trying to find the errors in this sql statement INSERT INTO images(user, server, img-name, download, download-url, image-loc) VALUES(test@test.com, 3, Penguins.jpg, no, GaNfT, 69Z8PwE0uJLfRNDijPenguins.jpg) I also have an auto increment column but as I understand it you shoudln't supply a value It comes out with this error You have an ...</description>
			<content:encoded><![CDATA[ <p>I'm trying to find the errors in this sql statement</p>

<pre><code class="language-sql">INSERT INTO images(user, server, img-name, download, download-url, image-loc) VALUES(test@test.com, 3, Penguins.jpg, no, GaNfT, 69Z8PwE0uJLfRNDijPenguins.jpg)
</code></pre>

<p>I also have an auto increment column but as I understand it you shoudln't supply a value</p>

<p>It comes out with this error</p>

<pre><code class="language-sql">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 '-name, download, download-url, image-loc) VALUES(test@test.com, 3, Penguin' at line 1
</code></pre>

<p>I have no idea what the error is, can anybody help?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>fheppell</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452297/sql-statement-issues</guid>
		</item>
				<item>
			<title>Postgre convert non latin chars case</title>
			<link>http://www.daniweb.com/web-development/databases/threads/452293/postgre-convert-non-latin-chars-case</link>
			<pubDate>Fri, 12 Apr 2013 13:31:16 +0000</pubDate>
			<description> SELECT getdatabaseencoding(), current_setting('client_encoding'), current_setting('lc_ctype'), current_setting('lc_collate'), version(); returns UTF8 UNICODE C C PostgreSQL 9.1.7 on x86_64-unknown-linux-gnu, compiled by gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 64-bit select lower('ČĘĖĮ') returns ČĘĖĮ Actually what I want is to seach surnames with ILIKE which is not working for those chars. WHy this can be?</description>
			<content:encoded><![CDATA[ <pre><code class="language-sql">SELECT getdatabaseencoding(), current_setting('client_encoding'), current_setting('lc_ctype'), current_setting('lc_collate'), version();
</code></pre>

<p>returns</p>

<p>UTF8 UNICODE C C PostgreSQL 9.1.7 on x86_64-unknown-linux-gnu, compiled by gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 64-bit</p>

<pre><code class="language-sql">select lower('ČĘĖĮ')
</code></pre>

<p>returns ČĘĖĮ</p>

<p>Actually what I want is to seach surnames with ILIKE which is not working for those chars. WHy this can be?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>SPeed_FANat1c</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/452293/postgre-convert-non-latin-chars-case</guid>
		</item>
				<item>
			<title>How to achieve?</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452262/how-to-achieve</link>
			<pubDate>Fri, 12 Apr 2013 06:26:04 +0000</pubDate>
			<description>Hi to all just wanna ask how to achieve something like on show all data if a certain field on the table is equal to **2**. basically what im trying to make is a search form by the way the searching part is working it just that its showing all ...</description>
			<content:encoded><![CDATA[ <p>Hi to all just wanna ask how to achieve something like on show all data if a certain field on the table is equal to <strong>2</strong>. basically what im trying to make is a search form by the way the searching part is working it just that its showing all the data what i really need to achieve is show the data if <code>tablefiled==2</code></p>

<p>THE Table structure is</p>

<pre><code class="language-sql">Id    Name        Sdate         Active_view

1     Person 1    2013-04-1          2
2     Person 2    2013-04-5          1
3     Person 3    2013-04-25         1
4     Person 4    2013-04-1          2
5     Person 1    2013-04-1          1
</code></pre>

<p>The process that it undergo is<br />
$searchterm="2013-04-1"</p>

<p>output is</p>

<pre><code class="language-sql">Name          Serving Date  

Person 1      2013-04-1
Person 4      2013-04-1      
</code></pre>

<p>and my query is</p>

<pre><code class="language-sql">select * from advance where CONCAT_WS(' ',SDate,'/',Time) like '{$searchterm}%'  ORDER BY Id DESC
</code></pre>

<p>i tried also something like this but it now showing anything..</p>

<pre><code class="language-sql">select * from advance where Active_view==2 AND CONCAT_WS(' ',SDate,'/',Time) like '{$searchterm}%'  ORDER BY Id DESC
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>ehpratah</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452262/how-to-achieve</guid>
		</item>
				<item>
			<title>Mysqldump can&#039;t connect to localhost (Error 2003 &amp; 10049)</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452199/mysqldump-cant-connect-to-localhost-error-2003-10049</link>
			<pubDate>Thu, 11 Apr 2013 12:30:46 +0000</pubDate>
			<description>Hi all! I have a big problem that I would like some help. I use Mysql Workbenc 5.2CE. I changed the default port to 3301. The mysql server is up and running well (I access it from an app I'm making with VB.NET). The problem is I can't get mysqldump ...</description>
			<content:encoded><![CDATA[ <p>Hi all!</p>

<p>I have a big problem that I would like some help. I use Mysql Workbenc 5.2CE. I changed the default port to 3301. The mysql server is up and running well (I access it from an app I'm making with VB.NET). The problem is I can't get mysqldump to backup the database. I'm using the following code (in the command prompt)</p>

<pre><code class="language-sql">"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe", "--user=root  --password =mypassword" "--host = 127.0.0.1 --port 3301 --databases MySQL databasename -r ""C:\GreatestHR Backup\BackUpDataBase.sql"""
</code></pre>

<p>(Note: I would like to use an IP Address for host)</p>

<p>When I run that, I get the error: "mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (10049)<br />
when trying to connect ".</p>

<p>Can someone please help me on this? (People are not even talking about mysql's error 10049 online.)</p>

<p>I will appreciate any help.<br />
Thanks.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>savedlema</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452199/mysqldump-cant-connect-to-localhost-error-2003-10049</guid>
		</item>
				<item>
			<title>How to remove pattern from a text field</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452070/how-to-remove-pattern-from-a-text-field</link>
			<pubDate>Tue, 09 Apr 2013 22:57:53 +0000</pubDate>
			<description>Hi I have a site built on Wordpress which has a over 4,000 posts all with the suffix -2 at the end of the post name (due to me forgetting to clear the trash) before running an import). I would like to remove the -2 from the post names with ...</description>
			<content:encoded><![CDATA[ <p>Hi</p>

<p>I have a site built on Wordpress which has a over 4,000 posts all with the suffix -2 at the end of the post name (due to me forgetting to clear the trash) before running an import).</p>

<p>I would like to remove the -2 from the post names with a little bit of SQL so that for example my-example-post-2 becomes my-example-post and so on.</p>

<p>The table is wp-posts and the field is post_name.</p>

<p>I tried</p>

<pre><code class="language-sql">update wp_posts set post_name = 
replace(post_name,'-2','');
</code></pre>

<p>but this didn't work, I suspect but not sure, it may be because it looking for an actual post name of '-2' rather than the equivalent of %-2</p>

<p>Any help really appreciated as although I have backed up my database and will do before running any SQL I don't want to realy mess it up be experimenting on my own further.</p>

<p>Thanks<br />
Mark</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>magicmarkuk</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452070/how-to-remove-pattern-from-a-text-field</guid>
		</item>
				<item>
			<title>Is this possible ???</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/452039/is-this-possible-</link>
			<pubDate>Tue, 09 Apr 2013 14:19:25 +0000</pubDate>
			<description>Hey guys, I was wondering if you could tell me if this is even possible or if it can be done another way??? So i have a database with 6 tables all the databases have the same columns except for the tables name ahead of the generic headers pub_name, Hotel_name, ...</description>
			<content:encoded><![CDATA[ <p>Hey guys,</p>

<p>I was wondering if you could tell me if this is even possible or if it can be done another way???</p>

<p>So i have a database with 6 tables all the databases have the same columns except for the tables name ahead of the generic headers pub_name, Hotel_name, restaurant_Name etc.</p>

<p>Estentially i want to take all the values that meet the search criteria out of the 6 tables so if i want all the restaurants hotels and pubs that are in ennis can i do it??</p>

<p>Thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>joseph.lyons.754</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/452039/is-this-possible-</guid>
		</item>
				<item>
			<title>Search between two date range Error</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/451630/search-between-two-date-range-error</link>
			<pubDate>Thu, 04 Apr 2013 02:56:46 +0000</pubDate>
			<description> Hi need some help suggestion I am trying to search data form two date range but it seems not working properly when i search for $from_date = &quot;2013-04-01&quot;; $to_date = &quot;2013-04-04&quot;; $query = mysql_query(&quot;SELECT * FROM date WHERE Date between '&quot; . $from_date . &quot;' AND '&quot; . $to_date . ...</description>
			<content:encoded><![CDATA[ <pre><code class="language-sql">Hi need some help suggestion 

I am trying to search data form two date range but it seems not working properly when i search for


$from_date = "2013-04-01";
$to_date = "2013-04-04";

$query = mysql_query("SELECT * FROM date WHERE Date between '" . $from_date . "'  AND '" . $to_date . "' ORDER by id DESC");
</code></pre>

<p>it will only return</p>

<pre><code class="language-sql">Guest 1           2013-04-01
Guest 2           2013-04-02
Guest 3           2013-04-03
Guest 4           2013-04-01
</code></pre>

<p>it is omitting</p>

<pre><code class="language-sql">Guest 5           2013-04-04
</code></pre>

<p>and i also try uisng this query</p>

<p><code>$query = mysql_query("SELECT * FROM date WHERE Date &gt;= '" . $from_date . "'  AND Date &lt;= '" . $to_date . "' ORDER by id DESC");</code></p>

<p>it will show just the same result</p>

<pre><code class="language-sql">Here's my table

id  Name                  Date

1   Guest 1           2013-04-01
2   Guest 2           2013-04-02
3   Guest 3           2013-04-03
4   Guest 4           2013-04-01
5   Guest 5           2013-04-04
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>ehpratah</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/451630/search-between-two-date-range-error</guid>
		</item>
				<item>
			<title>sql formula</title>
			<link>http://www.daniweb.com/web-development/databases/threads/451548/sql-formula</link>
			<pubDate>Wed, 03 Apr 2013 06:17:06 +0000</pubDate>
			<description>Good day, I am having troulbe with my computation here. i want to compute for the Custom_Haulage_In_Transit but when i exec my sp the value of the Custom_Haulage_In_Transit is 0. can anyone help me with this please.. here is my code SELECT distinct MATERIAL ,Description ,Material_Type -- ,Requested_Delivery_Date ,ATP_check ,Delivering_Plant ...</description>
			<content:encoded><![CDATA[ <p>Good day,</p>

<p>I am having troulbe with my computation here. i want to compute for the Custom_Haulage_In_Transit but when i exec my sp the value of the  Custom_Haulage_In_Transit is 0. can anyone help me with this please..</p>

<p>here is my code</p>

<pre><code class="language-sql">SELECT      distinct    MATERIAL
                ,Description
                ,Material_Type
--              ,Requested_Delivery_Date
                ,ATP_check
                ,Delivering_Plant
                ,Order_Quantity
                ,Held_by_Finance
                ,Rejected_OOS
                ,Rejected_Others
                ,Open_Order_Quantity
                ,case when Order_Quantity_NKA is null 
                        then '0' 
                        else Order_Quantity_NKA 
                        end 
                as Order_Quantity_NKA

                ,case when Order_Quantity_RKA is null 
                        then '0' 
                        else Order_Quantity_RKA 
                        end 
                as Order_Quantity_RKA

                ,case when Order_Quantity_Others is null 
                        then '0' 
                        else Order_Quantity_Others 
                        end 
                as Order_Quantity_Others

                ,case when Stock is null 
                        then '0' 
                        else Stock 
                        end 
                as Stock

                ,case when DSD_Delivery is null 
                        then '0' 
                        else DSD_Delivery 
                        end 
                as DSD_Delivery

                ,case when OUtBound_Haulage is null 
                        then '0' 
                        else OUtBound_Haulage 
                        end 
                as OUtBound_Haulage

                ,case when Total_OutBound_items is null 
                        then '0' 
                        else Total_OutBound_items 
                        end 
                as Total_OutBound_items

                ,case when InBound_Haulage is null 
                        then '0' 
                        else InBound_Haulage 
                        end 
                as InBound_Haulage

                ,case when Haulage_In_Transit is null 
                        then '0' 
                        else Haulage_In_Transit 
                        end 
                as Haulage_In_Transit

                ,Process_Order

                ,case when Total_Inbound_Items is null 
                        then '0' 
                        else Total_Inbound_Items  
                        end 
                as Total_Inbound_Items 


                --pivot
                ,case when [IN TRANSIT] is null 
                        then '0' 
                        else [IN TRANSIT]  
                        end 
                as [IN TRANSIT] 

                ,case when HAULAGE is null 
                        then '0' 
                        else HAULAGE  
                        end 
                as HAULAGE

                ,case when PRODUCTION is null 
                        then '0' 
                        else PRODUCTION  
                        end 
                as PRODUCTION


                --computation
                ,  case when Custom_Haulage_In_Transit is null 
                        then '0' 
                        else  (Haulage_In_Transit * [IN TRANSIT])/100 
                        end 
                as Custom_Haulage_In_Transit


                ,case when Custom_Inbound_Haulage is null 
                        then '0' 
                        else ((InBound_Haulage - HAULAGE) / 100)
                        end 
                as Custom_Inbound_Haulage



                ,case when Custom_Process_Order is null 
                        then '0' 
                        else (Process_Order * PRODUCTION) / 100
                        end 
                as Custom_Process_Order  


                ,case when Custom_Total_Inbound  is null 
                        then '0' 
                        else ((Haulage_In_Transit  *  [IN TRANSIT])/100 + (InBound_Haulage - HAULAGE)/100 + (Process_Order * PRODUCTION) / 100) 
                        end 
                as Custom_Total_Inbound


                ,case when Custom_ATP_Quantity is null 
                        then '0' 
                        else ((Stock - Total_OutBound_items) + Custom_Total_Inbound) 
                        end 
                as Custom_ATP_Quantity
FROM(
    SELECT
             *  
    FROM 
        (
            SELECT 
                REPORT.MATERIAL
                ,REPORT.Description
                ,REPORT.Material_Type
--              ,REPORT.Requested_Delivery_Date
                ,REPORT.ATP_check
                ,REPORT.Delivering_Plant
                ,REPORT.Order_Quantity
                ,REPORT.Held_by_Finance
                ,REPORT.Rejected_OOS
                ,REPORT.Rejected_Others
                ,REPORT.Open_Order_Quantity
                ,REPORT.Order_Quantity_NKA
                ,REPORT.Order_Quantity_RKA
                ,REPORT.Order_Quantity_Others
                ,REPORT.Stock
                ,REPORT.DSD_Delivery
                ,REPORT.OUtBound_Haulage
                ,REPORT.Total_OutBound_items
                ,REPORT.InBound_Haulage 

                ,REPORT.Haulage_In_Transit
                ,REPORT.Process_Order
                ,REPORT.Total_Inbound_Items

                ,REPORT.Custom_Haulage_In_Transit
                ,REPORT.Custom_Inbound_Haulage
                ,REPORT.Custom_Process_Order
                ,REPORT.Custom_Total_Inbound
                ,REPORT.Custom_ATP_Quantity 

                ,TYPES.*

                FROM CO09_Report REPORT
                    INNER JOIN TBLTYPES TYPES
                        ON REPORT.MATERIAL = TYPES.TXTMATERIAL


        )AS T
    PIVOT (SUM(PERCENTAGE)
        FOR [TYPE] IN ([In Transit] , [HAULAGE], [PRODUCTION] ))
        AS pvt

) temp
</code></pre>

<p>i want to compute for the ff.. Custom_Haulage_In_Transit,Custom_Inbound_Haulage,Custom_Process,Custom_Total_Inbound and Custom_ATP_Quantity</p>

<p>the formula is already there</p>

<p>thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>cyberdaemon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/451548/sql-formula</guid>
		</item>
				<item>
			<title>MySQL Calculate Percentage</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/451409/mysql-calculate-percentage</link>
			<pubDate>Mon, 01 Apr 2013 15:44:27 +0000</pubDate>
			<description>Hello All! I have a MySQL database with 4 items, id (numerical), group_name, employees, and surveys. I need to in my select calulate the percentage of 'employees' who my the number in 'surveys' have taken the survey. This is the statement I have now: SELECT group_name, employees, surveys, COUNT( surveys ...</description>
			<content:encoded><![CDATA[ <p>Hello All!</p>

<p>I have a MySQL database with 4 items, id (numerical), group_name, employees, and surveys.</p>

<p>I need to in my select calulate the percentage of 'employees' who my the number in 'surveys' have taken the survey.</p>

<p>This is the statement I have now:</p>

<pre><code class="language-sql">SELECT group_name, employees, surveys, COUNT( surveys ) AS percentage, 
            ((COUNT( * ) / ( SELECT COUNT( * ) FROM db_test)) * 100 ) AS percentage
        FROM db_test
        ORDER BY surveys
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>mattsheets</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/451409/mysql-calculate-percentage</guid>
		</item>
				<item>
			<title>Create View</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/451318/create-view</link>
			<pubDate>Sun, 31 Mar 2013 10:05:00 +0000</pubDate>
			<description>I'm trying to get to grips with this create view thingy, but can't see it. This creats my view mysql_query(&quot;CREATE VIEW list AS SELECT AlbumId,Title FROM album, LEFT JOIN artist ON album.artistId = artist.ArtistId ORDER BY album.Title&quot;)or die (&quot;no dice pal &quot;.mysql_error()); that works, and creats it fine. But when ...</description>
			<content:encoded><![CDATA[ <p>I'm trying to get to grips with this create view thingy, but can't see it.</p>

<p>This creats my view</p>

<pre><code class="language-sql">mysql_query("CREATE VIEW list AS 
   SELECT AlbumId,Title FROM album,
   LEFT JOIN artist ON album.artistId = artist.ArtistId ORDER BY album.Title")or die ("no dice pal   ".mysql_error());
</code></pre>

<p>that works, and creats it fine. But when I run the query</p>

<pre><code class="language-sql">  &lt;table class='tables' align='center' border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Album&lt;/th&gt;&lt;th&gt;Artist&lt;/th&gt;
  &lt;/tr&gt;
  &lt;?php
  mysql_set_charset('utf8');
  $list=mysql_query("SELECT * FROM list");
   while($row=mysql_fetch_array($list)){
   $alb=$row['AlbumId'];
   $title=$row['Title'];
   $art=$row['Name'];

  echo"&lt;tr&gt;
      &lt;td&gt;".$alb."&lt;/td&gt;&lt;td&gt;".$title."&lt;/td&gt;&lt;td&gt;".$art."&lt;/td&gt;
      &lt;/tr&gt;";
   }

?&gt;
  &lt;/table&gt;
</code></pre>

<p>the last column in the table  'Artist' is blank, what am I missing here guys, aside from a few million brain cells?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>TonyG_cyprus</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/451318/create-view</guid>
		</item>
				<item>
			<title>help for adding songs in the database table</title>
			<link>http://www.daniweb.com/web-development/databases/threads/451097/help-for-adding-songs-in-the-database-table</link>
			<pubDate>Wed, 27 Mar 2013 18:47:18 +0000</pubDate>
			<description>I don't know how to add songs in the database along with their link, content_type, duration, size, etc. I don't know which query &amp; what datatype will be required to add the songs inside a database table. Since music file is a .mp3 or .wav data I cannot possibly add ...</description>
			<content:encoded><![CDATA[ <p>I don't know how to add songs in the database along with their link, content_type, duration, size, etc.<br />
I don't know which query &amp; what datatype will be required to add the songs inside a database table.<br />
Since music file is a .mp3 or .wav data I cannot possibly add it inside the database table without the proper knowledge.<br />
I checked it on the internet but did not found any thing special.<br />
Also what is the maximum size of the song that I can store in the database table?</p>

<p>I only need to know how a song can be added inside the database table?<br />
The datatype for the song required?<br />
The maximum size of the song that can be stored inside the database, since i have song files that are about 7MB-10MB large.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>vinnitro</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/451097/help-for-adding-songs-in-the-database-table</guid>
		</item>
				<item>
			<title>INSERT VALUES</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/450900/insert-values</link>
			<pubDate>Mon, 25 Mar 2013 05:25:28 +0000</pubDate>
			<description>Hi to all, I try to insert a values in SQLSERVER 2005,It shows &quot;Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table 'designation' when IDENTITY_INSERT is set to OFF.&quot; BEGIN TRAN INSERT INTO DESIGNATION (ID,DESIGNATION) VALUES(17,'TEST') COMMIT Kindly Suggest How to Solve ...</description>
			<content:encoded><![CDATA[ <p>Hi to all,</p>

<p>I try to insert a values in SQLSERVER 2005,It shows "Msg 544, Level 16, State 1, Line 1<br />
Cannot insert explicit value for identity column in table 'designation' when IDENTITY_INSERT is set to OFF."</p>

<pre><code class="language-sql">BEGIN TRAN
INSERT INTO DESIGNATION (ID,DESIGNATION) VALUES(17,'TEST')
COMMIT
</code></pre>

<p>Kindly Suggest How to Solve this ISsue..</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>pearl.kumar1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/450900/insert-values</guid>
		</item>
				<item>
			<title>sql formula</title>
			<link>http://www.daniweb.com/web-development/databases/threads/450895/sql-formula</link>
			<pubDate>Mon, 25 Mar 2013 03:57:26 +0000</pubDate>
			<description>Good day, I am having a probem with my sql. I want to create a formula for my pivot field.. here is my code... SELECT * FROM ( SELECT REPORT.MATERIAL ,REPORT.Description ,REPORT.Material_Type ,REPORT.ATP_check ,REPORT.Delivering_Plant ,REPORT.Order_Quantity ,REPORT.Held_by_Finance ,REPORT.Rejected_OOS ,REPORT.Rejected_Others ,REPORT.Open_Order_Quantity ,REPORT.Order_Quantity_NKA ,REPORT.Order_Quantity_RKA ,REPORT.Order_Quantity_Others ,REPORT.Stock ,REPORT.DSD_Delivery ,REPORT.OUtBound_Haulage ,REPORT.Total_OutBound_items ,REPORT.InBound_Haulage ,REPORT.Haulage_In_Transit ,REPORT.Process_Order ,REPORT.Total_Inbound_Items ...</description>
			<content:encoded><![CDATA[ <p>Good day,<br />
I am having a probem with my sql. I want to create a formula for my pivot field.. here is my code...</p>

<pre><code class="language-sql">SELECT
        *

FROM 
    (
        SELECT 
            REPORT.MATERIAL
            ,REPORT.Description
            ,REPORT.Material_Type
            ,REPORT.ATP_check
            ,REPORT.Delivering_Plant
            ,REPORT.Order_Quantity
            ,REPORT.Held_by_Finance
            ,REPORT.Rejected_OOS
            ,REPORT.Rejected_Others
            ,REPORT.Open_Order_Quantity
            ,REPORT.Order_Quantity_NKA
            ,REPORT.Order_Quantity_RKA
            ,REPORT.Order_Quantity_Others
            ,REPORT.Stock
            ,REPORT.DSD_Delivery
            ,REPORT.OUtBound_Haulage
            ,REPORT.Total_OutBound_items
            ,REPORT.InBound_Haulage
            ,REPORT.Haulage_In_Transit
            ,REPORT.Process_Order
            ,REPORT.Total_Inbound_Items
            ,REPORT.Custom_Haulage_In_Transit
            ,REPORT.Custom_Inbound_Haulage
            ,REPORT.Custom_Process_Order
            ,REPORT.Custom_Total_Inbound
            ,REPORT.Custom_ATP_Quantity 
            ,TYPES.*

            FROM CO09_Report REPORT
                INNER JOIN TBLTYPES TYPES
                    ON REPORT.MATERIAL = SUBSTRING(TYPES.TXTMATERIAL,13,18)

--WHERE REPORT.Custom_ATP_Quantity &gt;  0 


    )AS T
PIVOT (SUM(PERCENTAGE)
    FOR [TYPE] IN ([IN TRANSIT], [HAULAGE], [PRODUCTION]))
    AS pvt 
</code></pre>

<p>my problem is that how can i multiply REPORT.Haulage_In_Transit to [IN TRANSIT] that is located in the pivot<br />
can anyone has an idea about this..?</p>

<p>thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/16">Databases</category>
			<dc:creator>cyberdaemon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/threads/450895/sql-formula</guid>
		</item>
				<item>
			<title>Phpmyadmin ai by 2?</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/450790/phpmyadmin-ai-by-2</link>
			<pubDate>Sat, 23 Mar 2013 14:01:06 +0000</pubDate>
			<description>Hi, Can you set auto increment in phpmyadmin to be 2? So that it goes 1, 3, 5, 7etc? Thanks...............</description>
			<content:encoded><![CDATA[ <p>Hi,</p>

<p>Can you set auto increment in phpmyadmin to be 2? So that it goes 1, 3, 5, 7etc?</p>

<p>Thanks...............</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>GlenRogers</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/450790/phpmyadmin-ai-by-2</guid>
		</item>
				<item>
			<title>MS sql 2012 trigger + how to get inserted values</title>
			<link>http://www.daniweb.com/web-development/databases/ms-sql/threads/450685/ms-sql-2012-trigger-how-to-get-inserted-values</link>
			<pubDate>Fri, 22 Mar 2013 04:44:54 +0000</pubDate>
			<description>I have a trigger on insert CREATE TRIGGER [dbo].[InsertNewCustomersAsGroupMembers] ON [CustomerBase].[dbo].[Cutomers] AFTER INSERT AS BEGIN SET NOCOUNT ON; -- Insert statements for trigger here DECLARE @inserterdCustomerID uniqueidentifier UPDATE [CustomerBase].[dbo].[GroupMembers] ?---? END GO I want to get the values of the inserted record at [CustomerBase].[dbo].[customers] into the trigger inorder to update ...</description>
			<content:encoded><![CDATA[ <p>I have a trigger on insert</p>

<pre><code class="language-sql">    CREATE TRIGGER [dbo].[InsertNewCustomersAsGroupMembers]
    ON  [CustomerBase].[dbo].[Cutomers]
    AFTER INSERT
    AS 
    BEGIN

        SET NOCOUNT ON;

        -- Insert statements for trigger here
        DECLARE @inserterdCustomerID uniqueidentifier
        UPDATE [CustomerBase].[dbo].[GroupMembers]
        ?---?

    END
    GO
</code></pre>

<p>I want to get the values of the inserted record at [CustomerBase].[dbo].[customers]  into the trigger inorder to update [CustomerBase].[dbo].[GroupMembers] table. How can i get them?</p>

<p>thank you in advance</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/ms-sql/127">MS SQL</category>
			<dc:creator>jrosh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/ms-sql/threads/450685/ms-sql-2012-trigger-how-to-get-inserted-values</guid>
		</item>
				<item>
			<title>Ignore white space in MATCH AGAINST</title>
			<link>http://www.daniweb.com/web-development/databases/mysql/threads/450605/ignore-white-space-in-match-against</link>
			<pubDate>Thu, 21 Mar 2013 05:15:49 +0000</pubDate>
			<description>Hi All, I am uisng Mysql DB and i have a task for suggesting Categories based on User keyword input. I have written the query as below but i need to ignore white spaces while matching, how can we achieve it SELECT search.*, MATCH (name) AGAINST ('black' IN BOOLEAN MODE) ...</description>
			<content:encoded><![CDATA[ <p>Hi All,</p>

<p>I am uisng Mysql DB and i have a task for suggesting Categories based on User keyword input.<br />
I have written the query as below but i need to ignore white spaces while matching, how can we achieve it</p>

<pre><code class="language-sql">SELECT search.*,
MATCH (name) AGAINST ('black' IN BOOLEAN MODE) AS name_match,
MATCH (keywords) AGAINST ('black' IN BOOLEAN MODE) AS keyword_match,
MATCH (description) AGAINST ('black' IN BOOLEAN MODE) AS description_match
FROM search
WHERE MATCH (name, keywords, description) AGAINST ('black' IN BOOLEAN MODE)
ORDER BY (name_match * 3  + keyword_match * 2  + description_match) DESC LIMIT 0,100;
</code></pre>

<p>I tried using replace() which were throwing error</p>

<pre><code class="language-sql">SELECT search.*,
    MATCH (replace(`name`,' ','')) AGAINST ('black' IN BOOLEAN MODE) AS name_match,
    MATCH (replace(`keywords`,' ','')) AGAINST ('black' IN BOOLEAN MODE) AS keyword_match,
    MATCH (replace(`description`,' ','')) AGAINST ('black' IN BOOLEAN MODE) AS description_match
    FROM search
    WHERE MATCH (name, keywords, description) AGAINST ('black' IN BOOLEAN MODE)
    ORDER BY (name_match * 3  + keyword_match * 2  + description_match) DESC LIMIT 0,100;
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/databases/mysql/126">MySQL</category>
			<dc:creator>deepak.fugo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/databases/mysql/threads/450605/ignore-white-space-in-match-against</guid>
		</item>
			</channel>
</rss>