I need to increment the number of comments on an Entries Table, the SQL for this would be:
UPDATE entries SET comments = comments + 1 WHERE entry_id = 123;
And i was wondering how to do this using Active Record Class form Code Igniter.
http://codeigniter.com/user_guide/database/active_record.html#update
...
Hello SO,
I am starting to use cakePHP for the first time with a hobby project. It looks like cakePHP supports LDAP easily enough as well as any DB. If the project goes well, I am thinking of letting the general public use the site, which means that there will (potentially) be a lot of users (a lot is relative, I guess, I'd be shocked...
I want to use LIKE clause and IN clause together.
e.g: Currently my query is -
SELECT
*
FROM
[USER_DETAILS]
WHERE
[NAME] LIKE 'Dev%' OR
[NAME] LIKE 'Deb%' OR
......
......
How can i use IN clause to achieve this?
Can someone please help? :)
...
its been sometime since i used corelated subqueries, i am not sure if i am doing this right. in my subquery 2nd last line, i am trying to get node.id from the outer table. when i try executing the query, i get
Error Code: 1054 Unknown column
'node.id' in 'where clause')
select node.id, node.title, depthLookup.depth
from posts no...
I have a table Books in my MySQL database which has the columns Title (varchar(255)) and Edition (varchar(20)). Example values for these are "Introduction to Microeconomics" and "4".
I want to let users search for Books based on Title and Edition. So, for example they could enter "Microeconomics 4" and it would get the proper result. My...
I try to execute the query below but I got an error saying"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.". I try to convert the date and cast the date but same error will comes out.
select DATEDIFF(YEAR,cast(Startdate as datetime),isnull(cast(Enddate as datetime), GETDATE()))
fro...
I have a simple query which returns 25,026 rows:
MySqlCommand cmd = new MySqlCommand("SELECT ID FROM People", DB);
MySqlDataReader reader = cmd.ExecuteReader();
(ID is an int.) If I just do this:
int i = 0;
while (reader.Read()) i++;
i will equal 25026. However, I need to do some processing on each ID in my loop; each iteration e...
Does anyone know how to write a script in stored proc to run the table based on the variable (or will it possible to do so?)?
for example:
I have 3 tables name called customer, supplier, and support
when user input 1, then run table customer, 2 table supplier and 3 table support
declare @input int;
if @input =1
begin
declare @table ...
Hi,
I am studing SQL, and I would like your advice, to see if my code is written properly, or better way to do it.
This script create:
a table to store IPs address that are Black Listed
a sproc to allow spitting an IP address in 4 octet
a SPROC that allow to check if a IP is Black Listed or not
Please let me know! thanks!
-- Black Lis...
dear i need to get query from 3 tables
i try to show how i need result in picture
hope this will explain every thing.
...
i have the following key:
ALTER TABLE dbo.Table ADD CONSTRAINT PK_ID PRIMARY KEY CLUSTERED
(
ID ASC
)
so i have clustered index and primary key on ID column.
Now i need to drop clustered index (i want to create new clustered index on another column), but retain primary key.
Is it possible?
...
I got a two tables
tblGoals
-name
-url
-siteID
tblUrlCollection
-url
-siteID
How do I count how many times every "url" from tblGoals is in tblUrlCollection using "url" and "siteID" as input?
Would like to use like or something so I can add wildcards to the end of the "url" input parameter.
Please help me out - thanks a lot.
Perfor...
Hi,
I have many TextBOX in asp.net which accepts the value from user and stores it to SQL DB through SQL SERVER..
When the user does not enter the value in the textbox, Which means i can allow the null for that filed in the table, But if its integer variable it stores 0, thats because
int HostelFees ;
HostelFees = TextBox1.Text;
//fu...
hi,
I used the following code, but the DateTime field at sql is
2005-04-08 00:00:00
I want to have the time too. where should i change
...
...
// Get the system date and time.
java.util.Date utilDate = new Date();
// Convert it to java.sql.Date
java.sql.Date date = new java.sql.Date(utilDate.getTime());
...
...
...
PreparedStatement ...
I've heard that in some programming languages it is faster to check if the length of a string is 0, than to check if the content is "". Is this also true for T-SQL?
Sample:
SELECT user_id FROM users WHERE LEN(user_email) = 0
vs.
SELECT user_id FROM users WHERE user_email = ''
...
Although I have been able to see the last ran query which is a Stored Procedure executed but I didn't get the parameters values with which the SP was invoked. Rather I got the following:
StoredProcedureName;1
from the following command:
DBCC INPUTBUFFER(SPID)
Where I got the SPID by viewing it in the ObjectExplorer->Management->Act...
Hi,
I have a sql statement like below. How can I add a single row(code = 0, desc = 1) to result of this sql statement without using union keyword? thanks.
select code, desc
from material
where material.ExpireDate ='2010/07/23'
...
I have an issue where a variable is not getting set by a select statement.
The select joins a table variable @contracts (which is used to control a loop) and then joins to the real contract and contract line tables.
my select is:
select top 1
@contract_id = c.contract_id
, @account = ch.account
, @service = c...
I have this SQL Server statement, and I am not sure why it is returning no records:
SELECT
contacts.firstname ,
contacts.lastname ,
contacts.address1 ,
contacts.city,
contacts.zip,
countries.title AS countrytitle,
states.title AS statetitle
FROM providers, payableinvoices, contacts
LEFT JOIN countrie...
Heyho,
I've gotta write a Procedure which Inserts a resultset from a select-statement into a table.
A co-worker of mine did something similar before to copy values from one table to another. His statement looks like this:
CREATE OR REPLACE PROCEDURE Co-Worker(
pId IN INT
)
AS
BEGIN
INSERT INTO Table1_PROCESSED
SELECT * FROM...