I have the following query:
select MIN(q.a), * FROM
(
sub-query1
) as q
UNION
sub-query2
How can I return the number of elements in query1 as a row of master-query?
If i use count (*) i´ve only the count
CountElementSub-Query1
i need some like that
rowA, rowB, rowC, CountElementSub-Query1
rowA, rowB, rowC, CountElementSub-Query1
rowA, rowB, rowC, CountElementSub-Query1
rowA, rowB, rowC, CountElementSub-Query1
I'm creating a list component with different numbers on each label ranging from 1 to 10. When clicked on a number I need it to bring up that many inputtext boxes one after another..
It's pretty much a multiplayer game that you select how many players are playing, then you input each name.. I'm so stuck it's ridiculous.. if anyone has a solution, or a different idea please help me out, thank you so much in advance.
Here is the code in question:
-----From index.php-----
require_once('includes/DbConnector.php');
// Create an object (instance) of the DbConnector
$connector = new DbConnector();
// Execute the query to retrieve articles
$query1 = "SELECT id, title FROM articles ORDER BY id DESC LIMIT 0,5";
$result = $connector-query($query1);
echo "vardump1:";
var_dump($result);
echo "\n";
/(!line 17!)/ echo "Number of rows in the result of the query:".mysql_num_rows($result)."\n";
// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector-fetchArray($result)){
echo ' ';
echo $row['title'];
echo ' ';
-----end index.php-----
-----included DbConnector.php-----
$settings = SystemComponent::getSettings();
// Get the main settings from the array we just loaded
$host = $settings['dbhost'];
$db = $settings['dbname'];
$user = $settings['dbusername'];
$pass = $settings['dbpassword'];
// Connect to the database
$this-link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
register_shutdown_function(array(&$this, 'close'));
} //end constructor
//* Function: query, Purpose: Execute a database query *
function query($query) {
echo "Query Statement: ".$query."\n";
$this-theQuery = $query;
return mysql_query($query, $this-link) or die(mysql_error());
}
//* Function: fetchArray, Purpose: Get array of query results *
function fetchArray($result) {
echo "<|";
var_dump($result);
echo "| \n";
/(!line 50!)/$res= mysql_fetch_array($result) or die(mysql_error());
echo $res['id']."-".$res['title']."-".$res['imagelink']."-".$res['text'];
return $res;
}
-----end DbConnector.php-----
-----Output-----
Query Statement: SELECT id, title FROM articles ORDER BY id DESC LIMIT 0,5 vardump1:bool(true)
PHP Error Message
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path to/index.php on line 17
Number of rows in the result of the query: <|bool(true) |
PHP Error Message
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /path to/DbConnector.php on line 50
My code is SELECT COUNT(*) FROM name_list WHERE [name]='a' LIMIT 1
It appears there is no limit clause in SQL Server. So how do i say tell me if 'a' exist in name_list.name?
Quite new with SQL I'm looking to export some data from a MySQL database into a csv file. I'm working locally (localhost).
Here is my SQL statement:
SELECT DISTINCT *
INTO
OUTFILE 'C:\Users\Martin\Downloads\result.csv'
FROM provider, location, provider_has_location
WHERE
provider.idprovider = provider_has_location.provider_idprovider AND
location.idLocation = provider_has_location.location_idLocation
LIMIT 20
MySQL return the following error:
Can't create/write to file 'C:UsersMartinDownloads esult.csv' (Errcode: 22)
Thanks for your help.
To do the equivalent of Python list comprehensions, I'm doing the following:
some_array.select{|x| x % 2 == 0 }.collect{|x| x * 3}
Is there a better way to do this...perhaps with one method call?
How would I write a SQL query that excludes a record if one (external) record from a one to many join matches a certain condition?
For example:
Details
ID
1
2
Items
DetailID Item
1 A
1 B
2 B
2 C
How would I select the detail records where the Items do not include 'A'?
Error of text2ltree
I can't use text2ltree. Any suggestion?
SELECT text2ltree(to_char(243, '09999999'))
*** Error ***
ERROR: syntax error at position 0
SQL state: 42601
I'm working on a custom forum system and I'm trying to figure out how to put a thread on the top of the list if a user posts in it.
I've got this for my query
SELECT
user_threads.threadID,
user_threads.title,
user_threads.uid,
user_threads.postDate,
thread_messages.posted
FROM
user_threads,
thread_messages
WHERE
parent = :parent
GROUP BY
user_threads.title
ORDER BY
thread_messages.posted
DESC
Which doesn't appear to be working. if I post in a new thread, it remains where it is on the list.
I have a query which is failing, as it needs to be using LEFT JOIN, as opposed to the default INNER JOIN used by the 'join' syntax:
var users = (from u in this._context.Users
join p in this._context.Profiles on u.ProfileID equals p.ID
join vw in this._context.vw_Contacts on u.ContactID equals vw.ID
orderby u.Code
select new { ID = u.ID, profileId = p.ID, u.ContactID, u.Code, u.UserName, vw.FileAs, p.Name, u.LastLogout, u.Inactive, u.Disabled }).ToList();
How would i re-write this so that is utilises a LEFT join?
hi every one,
RDBMS: mysql
colonne names: Timefrom,timeuntill, timespent as the following
type of the colonnes:Time.
timefrom timeuntill timespent
10:00:00 12:00:00 02:00:00
08:00:00 09:00:00 01:00:00
how could i get the sum of the timespent.
like this example it would be 03:00:00.
when doing select sum(timespent) from mytable it display: 030000.
please help. thanks.
Hi,
Am having a table with quetion_id , nominees and vote_count. In which the values for question_id and nominees are prepopulated from other tables with vote_count as zero.
If the users select some nominees the vote count should be incresed by one. The problem is How to connect the question_id and nominees like for this question_id this nominee is selected .
can some one give example for this situation..
If a do a query such as:
SELECT COUNT(*) as num FROM table WHERE x = 'y'
Will it always return a result, even when the query doesn't match any record? Or do i need to validate and make sure a row is returned as the result?
I need a SQL statement to retrieve records where it key (or any column) is in a associate table, for example:
documentId termId
4 1
4 2
3 3
5 1
This:
SELECT documentId
FROM table
WHERE termId IN (1,2,3)
...will retrieve any documentid value where the termid value is 1 or 2 or 3.
Is there something like this but return documentid values where the termid values are 1 and 2 and 3? Like an IN but with AND.
Given a list, how would I select a new list, containing a slice of the original list (Given offset and number of elements) ?
EDIT:
Good suggestions so far. Isn't there something specified in one of the SRFI's? This appears to be a very fundamental thing, so I'm surprised that I need to implement it in user-land.
Hi
I have a table (lets say it has one column called 'colLanguage') that contains a list of skills and has a full text index defined on it. One of the entries in the table is 'c#' but when I search for 'c#' (using the following SQL) I get no results back.
select *
from
FREETEXTTABLE(tblList, colLanguage, 'c#')
Can anyone help?
Thanks
K
I'm writing a dictionary app and need to do the usual word suggesting while typing.
LIKE somestrin% is rather slow (~1300ms on a ~100k row table) so I've turned to FTS3.
Problem is, I haven't found a sane way to search from the beginning of a string.
Now I'm performing a query like
SELECT word, offsets(entries) FROM entries WHERE word MATCH '"chicken *"';
, then parse the offsets string in code.
Are there any better options?
I wrote this statements but it is not work :(
... can you tell me why?
HTML:
<form action="join.php" method="post">
<label name="RoomName">Room1</label>
</form>
PHP:
$roomName = $_POST['RoomName'];
$roomID = "SELECT RoomID FROM rooms WHERE RoomName = $roomName";
I have been using MySQL for 2 years now, yet I still don't know what you actually do with the JOIN statement. I really didn't come across any situation where I was unable to solve a problem with the statements and syntax I already know (SELECT, INSERT, UPDATE, ordering, ...)
What does JOIN do in MySQL?
(Where) Do I need it?
Should I generally avoid it?
Hi,
I do not understand why following code does not work?
SELECT [column1], [column2]
FROM table where Column1 <> ('%TEST%')
ORDER BY 1
I want to have all rows where Column1 does not contain TEST
Thanks
What is the difference between % and * wildcards in MySQL?
In a query like so : "SELECT * FROM $table WHERE MATCH (message) AGAINST('$string*' IN BOOLEAN MODE)"
Hi guys:
I need to add a new SELECT statement whose search condition include something like leagueCode='nba%'.
I would like to know if the index against leagueCode is still exploitable or introduce any overhead after % is included in the target column.