I have 2 tables: 1st holds employees (of ones in any position) and the 2nd holds manager employee relations with id numbers.
I want to write a query like
1st field: name(employee),
2nd field: name(manager)
How can I do that?
...
I have the following tables:
posts (post_id, content, etc)
comments (comment_id, post_id, content, etc)
posts_categories (post_category_id, post_id, category_id)
and this query:
SELECT `p`.*
, COUNT(comments.comment_id) AS cmts
, posts_categories.*
, comments.*
FROM `posts` AS `p`
LEFT JOIN `posts_categories` ...
I upgraded my Delphi to 2010 version and I tried to open and run application written in Delphi 2006. The app is using mysql by dbexpress with libmysql.dll and a second driver found somewhere on the Internet.
I can't run it on 2010. I'm always getting "missing libmysql.dll library". I tried to get new version of it but it didn't help. C...
Hey. How would you optimize this SQL
SELECT SUM(tmp.cost) FROM (
SELECT DISTINCT clients.id as client, countries.credits_cost AS cost
FROM countries
INNER JOIN clients ON clients.country_id = countries.id
INNER JOIN clients_groups ON clients_groups.client_id=clients.id
WHERE clients_groups.group_id IN (1,2,3,4,5,6,7,8,9)
...
Hi,
I have the fallowing stored procedure:
CREATE PROCEDURE `get`(IN tb VARCHAR(50), IN id INTEGER)
BEGIN
SELECT * FROM tb WHERE Indx = id;
END//
When I call get(user,1) I get the following:
ERROR 1054 (42S22): Unknown column 'user' in 'field list'
...
Hi, every search query is saved in my database, but I want to Limit the Chracterlength for one single word: odisafuoiwerjsdkle --> length too much --> dont write in the database
my actually code is:
$search = $_GET['q'];
if (!($sql = mysql_query ('' . 'SELECT * FROM `history` WHERE `Query`=\'' . $search . '\''))) {
exit...
Hi, what is the best method to insert a search query into MySql
and check for double words? (for showing up the last searches and a collection of searches)
maybe something like this:
< ?php
/*------------------------------
Read and save the search query
-------------------------------*/
$querystat = mysql_real_escape_string($_GET['q'...
I have three update statements to be executed in PHP, i am getting the values of all these as return parameters. How to execute each statement independely and finally show the end user the result that it has been successfully updated.
<?php
public function name($parameter1,$parameter2.... $parametern) {
}
?>
Then...
I'm trying to group down records by their priority levels, e.g.
--- Priority: High ---
Records...
--- Priority: Medium ---
Records...
--- Priority: Low ---
Records...
Something like that, how do I do that in PHP? The while loop orders records by the priority column which has int value (high = 3, medium = 2,...
Let's say I have a class called Medium which can represent different types of media. For instance:
uploaded video
embedded video
uploaded image
embedded image
I represent these types with contants, like this:
class MediumAbstract
{
const UPLOAD = 0x0001;
const EMBED = 0x0010;
const VIDEO = 0x0100;
...
Hi,
I'm trying to a create an update statement along the following lines:
TABLE car: id | owner_id | type | status
An owner can have multiple cars.
UPDATE car c
SET c.type = 1
WHERE c.owner_id IN ($ids)
AND c.status = [1 IF THIS OWNER HAS A CAR WITH 1, ELSE A CAR WITH 0] // ... ???
$ids is reasonably small (under 5...
Hi, how can I pull only words with maximum 50 Characters from MYSQL?
$query = "SELECT * FROM example ORDER BY ID DESC LIMIT 200";
...
I am trying to modify an existing MySQL database for use in a new application.
I have a table of items (table_items), which has multiple fields, including "ItemID" and "ItemName".
I have another table (table_list) which has "ItemName" in it, but no ItemID. I need to either update this table to contain ItemID instead of ItemName, or creat...
I'm trying to run a simple query with $this->db in Kohana, but am running into some syntax issues when I try to use an alias for a table within my query:
$result = $this->db
->select("ci.chapter_id, ci.book_id, ci.chapter_heading, ci.chapter_number")
->from("chapter_info ci")
->where(array("ci.chapter_number" => $chapter, "ci.book...
We are developing an inventory tracking system. Basically we've got an order table in which orders are placed. When an order is payed, the status changes from 0 to 1. This table has multiple children in another table order_items.
This is the main structure.
CREATE TABLE order(
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_id...
Hello all,
Can anyone explain why this query returns an empty result.
SELECT *
FROM (`bookmarks`)
JOIN `tags` ON `tags`.`bookmark_id` = `bookmarks`.`id`
WHERE `tag` = 'clean'
AND `tag` = 'simple'
In my bookmarks table, I have a bookmark with an id of 70 and in my tags table i have two tags 'clean' and 'simple' both that have the colu...
I have this query and I have an error:
images = Image.find_by_sql('PREPARE stmt FROM \'
SELECT *
FROM images AS i
WHERE i.on_id = 1 AND i.on_type = "profile"
ORDER BY i.updated_at
LIMIT ?, 6\
'; SET @lower_limit := ((5 DIV 6) * 6); EXECUTE stmt USING @lower_limit;')
Mysql::Error: You have an error in
your SQL syntax; c...
Hello, I am trying to get my query to grab multiple rows while returning the maximum count of that query.
My query:
SELECT *, COUNT(*) as Max FROM tableA LIMIT 0 , 30
However, it is only outputting 1 record.
I would like to return multiple record as it was the following query:
SELECT * FROM tableA LIMIT 0 , 30
Do I have to use s...
I just found out because someone had a ' in their last name and it caused the script to not update anything after that. What's the best way to make their last name safe of any potental damaging characters?
...
Hi guys. I'm working through examples from a book on php/mysql development.
I'm working on a linux/apache environment.
I've set up a database and a user. I attempt to connect with this line of code:
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
I get this error:
Warning: mysql_connect()
[function.mysql-c...