PHP's PDO allows multiple querys to be executed at once, either via the query() method or as a prepared statement. Both of the following examples work:
// Two SQL queries
$query = "SELECT * FROM table; DROP table;"
// Execute via query()
$pdo->query($query);
// Execute via prepared statement
$stmt = $pdo->prepare($query);
$stmt->execu...
When i create a stored proc like the one below .. and upload it on my DOMAIN SERVER using cpanelx and myPHPadmin, DEFINER='domainusername'@'localhost' gets automatically injected ...
But the problem is my host does not let me give me privileges to CREATE DEFINER .... so what do i do to avoid this imjection of definers while importing th...
Hello,
I'm still quite a mySQL newbie, so I would like to do this right to avoid future mishaps.
What is the right way to detect when do I need to UPDATE an entry in a table or INSERT a new one?
Thank you.
...
I have the following tables:
Person, {"Id", "Name", "LastName"}
Sports, {"Id" "Name", "Type"}
SportsPerPerson, {"Id", "PersonId", "SportsId"}
For my query I want to get all the Persons that excersise a specific Sport whereas I only have the Sports "Name" attribute at my disposal. To retrieve the correct rows I've figured out the followi...
Hello guys,
I have the following MySQL table named "proposals":
proposal_id
proposal_user (int
proposal_book (int)
proposal_date (Y-m-d)
Users are going to propose books each month so there will be like 50-100 books per month. I would like to know if there's a way of writing a query that can return the most proposed books for a give...
I can't figure out how to fetch n random rows from a criteria instance:
Criteria criteria = session.createCriteria(Table.class);
criteria.add(Restrictions.eq('fieldVariable', anyValue));
...
Then what? I can't find any doc with Criteria API
Does it mean I should use HQL instead?
Thanx!
EDIT: I get the number of rows by:
int max =...
I'm using Drupal's db_fetch_array to fetch rows from my db_query. However, every row returned is equal to NULL. Typing the query into PHP myadmin works, so I have no idea whats going on. db_num_rows returns the number of rows as well. Here is the code:
if(count($rebuild_ids))
{
$ids=implode(",",$rebuild_ids);
$type_stmt = "SEL...
I have the following SQL statement which returns a single record as expected:
select * from geodatasource_cities C,
geodatasource_countries D
where C.CC_FIPS = D.CC_FIPS
and D.CC_ISO='AU'
and UCASE(TRIM(C.FULL_NAME_ND)) LIKE '%JAN JUE%';
However, If I use the following SQL statement, no records are returned. I ha...
I have a doubt. Assume R and S are 2 relations with attributes A and B respectively . If I have a query
Select *
From R, S
Where R.A = S.B
Does this work like a double For Loop in say c or c++
For( i=0; i<n; i++)
For( j=0; j<n; j++)
if (i == j)
//DO some work
...
I have this code:
$theQuery = mysql_query("SELECT phrase, date from wordList WHERE group='nouns'");
while($getWords=mysql_fetch_array($theQuery)) {
echo "$getWords[phrase] created on $getWords[date]<br>";
}
The query has 75,000 results, and every time I run the code I get an error.
...
i have a User with attributes
User.id
i have an object with
Object.id,
Object.name
i have a category with
Category.id,
Category.name,
Category.user_id
i have an association table with
category_id, object_id
user HABTM objects
objects HABTM users
categories belong to 1 user
how can i write a query to return a list of all objects Us...
I'm trying to build a MySQL query that uses the rows in a lookup table as the columns in my result set.
LookupTable
id | AnalysisString
1 | color
2 | size
3 | weight
4 | speed
ScoreTable
id | lookupID | score | customerID
1 | 1 | A | 1
2 | 2 | C | 1
3 | 4 | B | 1...
Hello guys,
I need some help with a complex SQL query. Here's my setup: there are two tables, one with authors, and another with books. The books table contains a field named "author" which holds author's id. If a book has more than one author, then the "author" field will contain all the authors ids separated by ";" (something like 2;3...
here is my SQL statement , i would like to find all the games that have the status 0 and names of teams that are like key_word or the sport's name that are like the key word.
The problem is that all the games that are displayed don't have status 0 .
What am i doing wrong?
sql="select * from games where games.status=0 and games.team_2_id...
Select Meterial_Id from transaction where CustId=1;
Instead of Meterial_Id i need to get the Meterial_name from Material table.....
...
I'm trying come up with the best method of synchronizing particular rows of 2 different database tables. So, for example there's 2 product tables in different databases as such...
Origin Database
product{
merchant_id,
product_id,
... additional fields
}
Destination Database
product{
merchant_id
product_id
.....
I need to insert multiple rows in my Mysql database.my rows are available in my dataset.
i am using for loop to send the row one by one is that right way?...
...
I have a working query that retrieves the data that I need, but unfortunately it is painfully slow (runs over 3 minutes). I have indexes in place, but I think the problem is the multiple dependent subqueries. I've been trying to rewrite the query using joins but I can't seem to get it to work. Any help would be greatly appreciated.
The ...
I'm designing a set of web apps to track scientific laboratory data. Each laboratory has several members, each of whom will access both their own data and that of their laboratory as a whole. Many typical queries will thus be expected to return records of multiple members (e.g. my mouse, joe's mouse and sally's mouse).
I think I have th...
I have a table:
id, datetime, event
i also have table dates:
date (Y-m-d format)
the problem is some days don't have any events, I would like them to show 0 (or null)
SELECT DATE_FORMAT(table.timestamp, '%Y-%m-%d') ydm, count(table.fkUID) FROM `table` where table.fkUID=$var group by ydm;
is there some way to join or use conditional...