Recently one of our client's websites fell prey to a SQL Injection attack due to a failure to sanitize query string parameters provided to the page. The vulnerable code has since been identified and is being corrected, but it got me wondering about some of the differences between how MySQL and SQL Server process multi-query strings.
The...
So, installing Ruby Enterprise Edition went fairly smoothly (except for a very odd quirk of the system I'm on, where I had to apt-get install build-essentials because there was no GCC...), but it failed to install any of the database gems properly. I mainly want to use MySQL. Here's the output of Ruby EE's ./installer during the mysql ge...
Will the following query evaluate to true (1), false (0), or NULL?
SELECT '%' LIKE ' % ';
the answer provided is
The '%' character is matched by '%', but not by the space characters surrounding it, so the expression evaluates to false.
+----------------+
| '%' LIKE ' % ' |
+----------------+
| 0 |
+----------------+
b...
If anyone could recommend a good book for learning mySQL as well, that would be great :).
I have two tables, tags, codes_tags
CREATE TABLE `tags` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCRE...
I'm building an "authors" page for my Wordpress blog that lists all the current site contributors along with various other information such as their number of published posts, the date of their last post, etc.
Google and the Wordpress Codex has pointed me toward using subqueries in MySQL to pull all the data I need in one query, and it'...
I have two tables:
Table "A":
+----------+
| item_id |
+----------+
| 10 |
| 20 |
| 30 |
| 40 |
+----------+
and table "B":
+----------+-------------+
| item_id | user_id |
+----------+-------------+
| 10 | 1 |
| 10 | 2 |
| 20 | 1 |
| 30 | 2 ...
I have the following script
select c.id
from ".TBL_COUPONS." as c
inner join ".TBL_BUSINESS." as b
on c.business_id = b.business_id
inner join ".TBL_BLOCATION." as l
on c.business_id = l.business_id
where
(match(c.name) against ('$search')
or
match (b.name,b.category,b.subcat) against ('$search'))
and l.zip = '$zip'
why ...
This is very simple but I keep getting a error for some reason:
MySQL view all error: 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 ''LIMIT 0,6'' at line 1
$max = 'LIMIT 0,6';
$data = mysql_query("SELECT * FROM `gallery` '$max'") or die( 'MySQL vie...
How to read from database and write into text file?
I want to write/copy (not sure what to call) the record inside my database into a text file. One row record in database is equal to one line in the text file. I'm having no problem in database.
For creating text file, it mentions FileStream and StreamWriter. Which one should I use?
...
I started by googling, and found this article which talks about mutex tables.
I have a table with ~14 million records. If I want to add more data in the same format, is there a way to ensure the record I want to insert does not already exist without using a pair of queries (ie, one query to check and one to insert is the result set is e...
Dear Everyone,
I have a table,
| PAGELETS | CREATE TABLE `PAGELETS` (
`page_key` int(32) unsigned NOT NULL,
`pagelet_serial` int(32) unsigned NOT NULL,
`pagelet_shingle` int(32) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
I would like to:
1) Find all the pagelet_shingles where quantity > 1 ( occurs more than once)
...
I am using and working on software which uses MySQL as a backend engine (it can use others such as PostgreSQL or Oracle or SQLite, but this is the main application we are using). The software was design in such way that the binary data we want to access is kept as BLOBs in individual columns (each table has one BLOB column, other columns...
I saved some data in the database using mysql_real_escape_string() so the single quotes are escaped like this '. It looks ok in the browser, but how can I convert it back to single quote when I save the text in a txt file?
...
I have a rather complicated trigger and I'm afraid it's execution time is too long. How can I measure it?
...
As some of you may know, use of the LIMIT keyword in MySQL does not preclude it from reading the preceding records.
For example:
SELECT * FROM my_table LIMIT 10000, 20;
Means that MySQL will still read the first 10000 records and throw them away before producing the 20 we are after.
So, when paginating a large dataset, high page num...
I've set up a virtual host on my local machine myhost.com, have installed zend there and am now trying to connect to the MySQLdatabase. I get the following error message:
Message: SQLSTATE[HY000] [2003] Can't connect to MySQL server on ''myhost.com'' (10060)
All the tips I've found via google haven't helped. I use kaspersky antivir...
I want to store data in string form to MySQL. I have created the tables in the MySQL.
I haven't worked with DATABASE ever. Can you please provide me code to store that data in the MySQL DB.
e.g. Let's say I have a string "stack_overflow" and there is a column "SiteName" in a table "SiteDetails" in the DataBase.
So how to store the string...
Hey, I have been looking for a simple way to track clicks on a link and store how many times the link has been clicked in a mysql database. Anyone have a solid approach on how to do this?
Thanks.
...
I'm planning on using client provided UUID's as the primary key in several tables in a MySQL Database.
I've come across various mechanisms for storing UUID's in a MySQL database but nothing that compares them against each other. These include storage as:
BINARY(16)
CHAR(16)
CHAR(36)
VARCHAR(36)
2 x BIGINT
Are there any better option...
I need a query that will return a table where each column is the count of distinct values in the columns of another table.
I know how to count the distinct values in one column:
select count(distinct columnA) from table1;
I suppose that I could just make this a really long select clause:
select count(distinct columnA), count(distinct...