Hi,
Is it possible to configure Solr so that the document similarity score would be in the range for example from 0 (no match) to 1 (complete document and query match).
Thanks!
I have some statistics I need to report on a monthly basis. I need my query to return 0's for statistics which aren't there. The only way I know to do this is to use SQL to generate a list of days within the specified time period and LEFT JOIN the statistic data that I need to report on.
Problem is.... I've never not selected from a table like that... how do I do that?
I'm executing the following query
SELECT COUNT(*)
FROM table
WHERE field1='value' AND (field2 = 1000 OR field3 = 2000)
There is one index over field1 and another composited over field2&field3.
I see MySQL always selects the field1 index and then makes a join using the other two fields which is quite bad because it needs to join 146.000 rows.
Suggestions on how to improve this? Thanks
I have one 'Transaction' entity object with 'Operations' navproperty with multiplicity of 'Many'.
When I'm adding only one operation per transaction nothing happens, but when I'm trying to add more than one operation,
db.SaveChanges() throws an exception like 'Subquery returned more than 1 value blah, blah, blah'
How can I solve that?
Help me guys please...
BTW... Could you tell me how can I see the exact query string that EF passes to Sql Server on db.SaveChanges() method?
main_product table
productid outward shopid
333 2 44//present
343 4 44//present
353 5 44//present
363 1 44//present
373 2 44//not present
min_product table
productid outward shopid
333 1 44
343 1 44
353 1 44
363 1 44
SELECT DISTINCT (A.productid),A.outward, B.productid,B.outward FROM main_product A INNER JOIN min_product B on B.productid=A.product_id where A.shopid='44' and B.shopid='44'
my question how can i INSERT OR UPDATE in one query using mysql by checking if it is present or not
if present update else insert
something like this?
INSERT
INTO mytable (key, value)
VALUES ($newkey, $newvalue)
ON DUPLICATE KEY UPDATE
SET value = $newvalue
Hello,
I'm trying to copy the contents of one table into another in Postgres, however it appears some rows aren't being copied correctly:
ActiveRecord::StatementInvalid:
PGError: ERROR: column "email_date" is
of type timestamp without time zone
but expression is of type character
varying HINT: You will need to rewrite
or cast the expression.
Is there any way I can have it automatically skip (or ignore) invalid rows?
Here's the query I'm using:
SET statement_timeout = 0; INSERT INTO emails3 SELECT * FROM emails
Is it possible to execute the two update queries in phpmyadmin together?
Like wise
UPDATE jos_menu SET home = 0 WHERE 1;
UPDATE jos_menu SET home = 1 WHERE id = 9;
Now can we copy both these queries together and Run it on phpmyadmin sql query panel?
will it be executed?
I'm in a situation now were I need to convert a datarow I've fetched from a query into a new instance of an object. I can do the obvious looping through columns and 'manually' assign these to properties of the object - or I can look into reflection such as this: http://www.codeproject.com/Articles/11914/Using-Reflection-to-convert-DataRows-to-objects-or
What would I base the decision on? Just scalability??
I am doing a query with three tables, the problem was one table has many occurrences of id of another.
sample data:
users: id
answers:
id:1
user_answer :1
id:1
user_answer :2
id:1
user_answer :3
Questions:
id:1
answers :answer description
id:2
answers :answer description
id:3
answers :answer description
How can I get all user information and all answer and its description, I used GROUP by user.id but it only returns only one answer.
I want to return something like this list all of users answer:
Name Q1 Q2
USERNAME ans1,ans2 ans1,ans2 comma separated description of answer here
What is the easiest and most efficient way to create an auto-increment counter for every data row in google appengine?
basically I want to give every row a unique row_number so that I can overcome the issue of only being able to get the first 1000 results in a select query. I can thus add a counter lies between condition and mine all the entires in the table.
is there a way to navigate through gird found on this page by passing parameters in query string?
http://pubrec3.hillsclerk.com/oncore/search.aspx?bd=01/01/2008&ed=12/31/2008&bt=O&lb=1000000&ub=1000000000&d=5/6/2010&pt=-1&dt=D,%20MTG&st=consideration
Or any code suggestion?
All example could i need in C#.
Hi,
I'm having a bit of trouble exporting a csv file that is created from one of my mysql tables using php.
The code I'm using prints the correct data, but I can't see how to download this data in a csv file, providing a download link to the created file. I thought the browser was supposed to automatically provide the file for download, but it doesn't. (Could it be because the below code is called using ajax?)
Any help greatly appreciated - code below, S.
include('../config/config.php'); //db connection settings
$query = "SELECT * FROM isregistered";
$export = mysql_query ($query ) or die ( "Sql error : " . mysql_error( ) );
$fields = mysql_num_fields ( $export );
for ( $i = 0; $i < $fields; $i++ )
{
$header .= mysql_field_name( $export , $i ) . "\t";
}
while( $row = mysql_fetch_row( $export ) )
{
$line = '';
foreach( $row as $value )
{
if ( ( !isset( $value ) ) || ( $value == "" ) )
{
$value = "\t";
}
else
{
$value = str_replace( '"' , '""' , $value );
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim( $line ) . "\n";
}
$data = str_replace( "\r" , "" , $data );
if ( $data == "" )
{
$data = "\n(0) Records Found!\n";
}
//header("Content-type: application/octet-stream"); //have tried all of these at sometime
//header("Content-type: text/x-csv");
header("Content-type: text/csv");
//header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=export.csv");
//header("Content-Disposition: attachment; filename=export.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo '<a href="">Download Exported Data</a>'; //want my link to go in here...
print "$header\n$data";
I have the following code. I would like username to take the value of the getUserName function however I am fighting with syntax. Can anybody tell me what should be the correct one?
$query = "SELECT user FROM users_entity WHERE username = getUserName()";
I have this table...
--------------------------------------
| user_id | status | status_date |
--------------------------------------
| 1 | Current | 2012-08-01 |
| 1 | Referral | 2012-03-14 |
| 2 | Referral | 2012-04-23 |
| | | |
--------------------------------------
How would I query to find a distinct user_id who has a referral date before 2012-06-30 AND either a current date of after 2012-06-30 or no current status record at all?
Database is MySQL.
I've got a combo box that's data provider is coming form a database query. Now I'd like to add one hard coded item to be included in the combobox a sort of reset item that would reset the combobox to display its prompt message.
Any idea how to do this?
Thanks!
Hi guys:
Suppose we got a original query as follows:
SELECT A, B, C FROM tblA
Now, I need to additional artificial rows like
SELECT 'Kyala', B, C FROM tblA when, for example, C = 100 to be inserted into the resultset.
How could I achieve it using a single SQL instead of relying on table variable or temp table?
I am trying to use open query to run a stored procedure in a remote database, and insert it into a table in my local database:
-- this works
exec remotesvr.sys.dbo.golden_table 'some', 'parameters'
While the above works out, I try the following:
insert into my_local_table
exec remotesvr.sys.dbo.golden_table 'some', 'parameters'
I get a SQL error to the effect of 'unable to begin a distributed transaction'.
Is there any way around this?, i.e. can I execute take the results of a remote stored procedure and put its contents in a local table?
Hi!
I'm writing a static page controller.
I get the menuname in the routes.rb and it's call the static controller show method.
match '/:menuname' = 'static#show'
And static_controller.rb:
@static=Staticpage.where("menuname =
?", params[:menuname])
But if I want print @static.title in the view, I get this error:
undefined method `title' for #
Whats wrong?
the SQL query looks good:
SELECT staticpages.* FROM staticpages WHERE (menuname = 'asd')
I have a query:
SELECT Content.content_name, Language2.Name, Language2.language_id,
Content.id, Content.content_description,
FROM Language AS Language2
LEFT JOIN contents AS Content ON (Language2.language_id = Content.language_id)
How do I select only the distinct content_name?
Hi,
I'm writing sql query to my SqlCommand, and some part of them looks like:
WHERE Path like N'+(select top 1 path from [Paths] where objectcode=@objectCode and objecttype=@objectType)+%' order by path desc,objecttype desc
I get no records , bu when I wrote the same in sql server 2005 i have plenty rows...
where path like (select top 1 path from [Paths] where objectcode='eg' and objecttype='0')+'%'
order by path desc
What's wrong ??
@objectType is 'eg'
Hi guys, I've got this table
CREATE TABLE `subevents` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(150) DEFAULT NULL,
`content` text,
`class` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM
Each row can have a different value in the 'class' field.
I'd like to select any number of rows, ordered randomly, as long as the sum of the values in the 'class' field is equal to 100.
How could I accomplish it directly in the MySQL query without doing it later in PHP?
Thanks everybody!
I have a table with
name varchar
address varchar
country varchar
city varchar
.....
to store address of location
example:
name|address|country
HaLong hotel|156 blahblah street|Vietnam
Hotel Ha Long|156 blah blah|Vietnam
Two rows above is duplicate data.
I have a form, when user submit new location. The code need to find akin records to give a message (ex: This location already in db, use it or create new?)
How to make a query to get akin record like this?
Heya,
I'm fetching a page using ajax (jquery) and appending certain data to the Requests query string to let the server know it shouldn't render the entire Page, just the view in question to the output buffer. I'm having no luck though, I can detect when the page needs to be rendered partially, but everything I've tried so far (including stuff like return PartialView()) isn't working.
Any ideas?
Thanks in advance.
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;