Tag: sql

60 votes
30 answers
2.9K views
How to return only the Date from a SQL Server DateTime datatype

SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 0

avatar
Corrin
0 1 0 9
asked 07 September, 2021
67 votes
30 answers
889 views
How to concatenate text from multiple rows into a single text string in SQL Server

Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this i

avatar
Xavier
0 1 0 9
asked 07 September, 2021
57 votes
30 answers
749 views
Finding duplicate values in a SQL table

It's easy to find duplicates with one field: SELECT name, COUNT(email) FROM users GROUP BY email HAVING

avatar
Elicia
0 1 0 9
asked 07 September, 2021
50 votes
30 answers
1.3K views
How do I import an SQL file using the command line in MySQL?

I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the comma

avatar
Sydney
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
406 views
Add a column with a default value to an existing table in SQL Server

How can I add a column with a default value to an existing table in SQL Server 2000 / SQL Server 2005?

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
1.7K views
How do I UPDATE from a SELECT in SQL Server?

In SQL Server, it is possible to insert rows into a table with an INSERT.. SELECT statement: INSERT INTO Table

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
60 votes
27 answers
2.9K views
What is the difference between "INNER JOIN" and "OUTER JOIN"?

Also how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in?

avatar
Louetta
0 1 0 9
asked 07 September, 2021
58 votes
7 answers
2.3K views
Codeigniter - multiple database connections

I have to retrieve a MySQL database information from master database and then connect to that database, and fe

avatar
Louetta
0 1 0 9
asked 07 September, 2021
53 votes
3 answers
1.2K views
Increment field of mysql database using codeigniter's active record syntax

I have the following php-codeigniter script which attempts to increment a field of a record using active-recor

avatar
Shanita
0 1 0 9
asked 07 September, 2021
62 votes
12 answers
3.1K views
Does CodeIgniter automatically prevent SQL injection?

I just inherited a project because the last developer left. The project is built off of Code Igniter. I&apo

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
55 votes
5 answers
1.1K views
How to add an ORDER BY clause using CodeIgniter's Active Record methods?

I have a very small script to get all records from a database table, the code is below. $query = $this->db-

avatar
Rudy
0 1 0 9
asked 07 September, 2021
52 votes
10 answers
1.8K views
How to select rows where column value IS NOT NULL using CodeIgniter's ActiveRecord?

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to select the rows i

avatar
Arline
0 1 0 9
asked 07 September, 2021
61 votes
11 answers
580 views
Inserting NOW() into Database with CodeIgniter's Active Record

I want to insert current time in database using mySQL function NOW() in Codeigniter's active record. The

avatar
Corrin
0 1 0 9
asked 07 September, 2021
58 votes
15 answers
847 views
How to print SQL statement in codeigniter model

I have a sql statement in my model, I then say $query = $this->db->query($sql, array(fields, fields1);

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
52 votes
13 answers
2.1K views
How to insert multiple rows from array using CodeIgniter framework?

I'm passing a large dataset into a MySQL table via PHP using insert commands and I'm wondering if it

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
60 votes
10 answers
2.6K views
how to get last insert id after insert query in codeigniter active record

I have an insert query (active record style) used to insert the form fields into a MySQL table. I want to get

avatar
Percy
0 1 0 9
asked 07 September, 2021
54 votes
10 answers
1.7K views
How can I do 'insert if not exists' in MySQL?

I started by googling and found the article How to write INSERT if NOT EXISTS queries in standard SQL which ta

avatar
Bryan
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
1.6K views
mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc... expects parameter 1 to be resource

I am trying to select data from a MySQL table, but I get one of the following error messages: mysql_fetch_

avatar
Boyd
0 1 0 9
asked 07 September, 2021
55 votes
18 answers
3.1K views
How can I sanitize user input with PHP?

Is there a catchall function somewhere that works well for sanitizing user input for SQL injection and XSS att

avatar
Trudy
0 1 0 9
asked 07 September, 2021
61 votes
16 answers
3K views
UTF-8 all the way through

I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in

avatar
Keith
0 1 0 9
asked 07 September, 2021