Given all the smarts around Hibernate and it's various caching strategies, how do I know if a certain operation is resulting in a physical database hit, or coming from the cache?
Hi,
I would like to select a random line in my database. I saw this solution on a website:
SELECT column FROM table
ORDER BY RAND()
LIMIT 1
This SQL query run but someone said me that it was a non performant query. Is there another solution ?
Thx
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
I am developing a WPF client program for some websites. It uses XML database. I am new to XML. Would someone please explain how to create,append(Most important),edit,read&encrypt XML file. It is a big question,i know . But, it is urgent.Have to complete the work ASAP. Searched in the internet, not getting correct info.
I wonder if this is possible with straight SQL on MySQL. I need to do SELECT COUNT(*) FROM on each table in the database and output results in one result set.
Is it possible to do with just SQL?
I have datas as unitprice with 10 decimal places in access database.
I want those decimal places to reduce when it comes to datagridview(round to 2 places).
How can i achieve this. Any idea.
Thanks in advance
Hi,
I converted an old sql server database from 2000 to 2005 and forgetten to add old indexes to the new db.
is there any way to copy the old indexes to the new db?
any help?
I was wondering if its possible to use a json-based schema-free, document-based database like Mongodb or Couchdb on a symfony project like its used for ruby-on-rails websites? And if yes, how can it be done?
Hello,
So when your using ASP.NET Wizards to create a login, it uses a set of auto generated tables using the aspnet_regsql.exe tool...
When you create a user using the wizard it generates a very long userID
"a40cf936-1596-4560-a26c-450792e2c8c0" I want to add users using another program that connects to this database... but how does visual studio auto-generate this ID. I want to auto-generate it as well
Any ideas? Thanks in advance.
-Scott
I am using c# with asp.net and SQL Server 2005 as backend. I want to use dropdown list control in a form to populate a textbox. The dropdown control is linked to a column in the database. How can I code this in c#?
Hi I want to know how to take a backup of database using programatically in VB.net of SQL Server 2005. if you are having and idea about it then pls send me the code for that.
When you have a slow database app, the first suggestions that people make is to:
Track the slow queries
Add appropriate indexes
In the case you are building your own application this is very logical, but when you use a CMS like Drupal, that are people have developed and tuned, is this approach valid?
I mean, aren't Drupal tables already fine-tuned for performance? Even if I try to see which queries are the slow ones, what could I do about it? Re-write Drupal core?!?
I have a class User and a class History. History has 'User' property, and User has 'Histories' property. So there's a database relationship.
But when I create a new User history class and set UserID property, I can't access the 'User' property.
var history = new History { UserID = 1 };
// history.User = null ???
How can I get the user?
Why is that when I search a row in my database, it ended up 0 results? In fact, there are rows that meet my search criterion when I view them manually, but the search button doesnt work as it is. Heres how
you can see there are rows that have '0000-00-00 00:00:00' in them, but when I used the search feature, it ended up like this:
take note that Im entering it in the right field which is 'AcctStopTime'.
TIA
I have a database that stores phone call records. Each phone call record has a start time and an end time. I want to find out what is the maximum amount of phone calls that are simultaneously happening in order to know if we have exceed the amount of available phone lines in our phone bank. How could I go about solving this problem?
SO I'm making a "basic" login file where a person logs in and the data that person entered on that form gets transfered to another form aka my database/table.
I think the problems is here but I'll post the rest of the code.
CREATE FUNCTION dbo.Function4
(
parameter1 int = 5,
parameter2 datatype
)
RETURNS Table1 TABLE (UserName, Password, Password_Confirmation, Assets)
AS
BEGIN
INSERT INTO Table1
(UserName, Password, Password_Confirmation, Assets)
VALUES
(a,b,c,d);
/*SELECT ... FROM ...*/
RETURN
END
This is the Login Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Login_Basic
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
Form3 Delta = new Form3();
private void label3_Click(object sender, EventArgs e)
{
}
private void Form2_Load(object sender, EventArgs e)
{
this.Hide();
}
private void textBox6_TextChanged(object sender, EventArgs e)
{
}
private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
{
int i = Convert.ToInt32(e.KeyChar);
if (!(Char.IsDigit(e.KeyChar) || Char.IsControl(e.KeyChar) || (e.KeyChar == '.' && this.Text.Contains(".") == false)))
e.Handled = true;
}
private void button1_Click(object sender, EventArgs e)
{
Delta.Show();
//if (textBox3.Text.Equals(""))
//{
// MessageBox.Show("Please enter your username");
//}
//else
//{
// this.Hide();
//}
// if (textBox4.Text.Equals(""))
//{
// MessageBox.Show("Please enter your password");
// }
// else
//{
// this.Hide();
// }
// if (textBox5.Text.Equals(""))
// {
// MessageBox.Show("Please re-enter your password");
// }
// else
// {
// this.Hide();
// }
//if (textBox6.Text.Equals(""))
//{
// MessageBox.Show("Please enter your amount");
//
// }
// else
// {
// this.Hide();
// }
}
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
/*if (textBox3.Text.Equals("") && textBox4.Text.Equals("") && textBox5.Text.Equals("") && textBox6.Text.Equals(""))
{
button1.Enabled = false;
}
else
{
button1.Enabled = true;
}*/
}
}
}
Here's a "Pic" of my database
http://s299.photobucket.com/albums/mm305/krsimms123/Code.jpg
Thanks in advance (I'll try and check this every few hours so I can help explain anything)
hi,
I have one table of 50k keywords and I am providing the auto-complete feature for these keywords based on count mechanism. But still getting the keywords takes time..
In what way would the database partitions have to be done for fast retrieving....
help me plz.....
I currently have 5 tables in MySQL database. Some of them share foreign keys and are interdependent of each other. I am displaying classes accordingly to their majors. Each class is taught during the fall, spring or all_year. In my database I have a table named semester which has an id, year, and semester fields. The semester field in particular is a tinyint that has three values 0, 1, 2. This signifies the fall, spring or all_year. When I display the query instead of having it show 0 or 1 or 2 can I have it show fall, spring etc? Extra: How can I add space to the end of each loop so the data doesn't look clustered?
Key
0 Fall
1 Spring
2 All-year
PHP
<?
try {
$pdo = new PDO ("mysql:host=$hostname;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
$query = $pdo->prepare("SELECT course.name, course.code, course.description, course.hours, semester.semester, semester.year
FROM course
LEFT JOIN major_course_xref ON course.id = major_course_xref.course_id
LEFT JOIN major ON major.id = major_course_xref.major_id
LEFT JOIN course_semester_xref ON course.id = course_semester_xref.course_id
LEFT JOIN semester ON course_semester_xref.semester_id = semester.id");
$query->execute();
if ($query->execute()){
while ($row = $query->fetch(PDO::FETCH_ASSOC)){
print $row['name'] . "<br>";
print $row['code'] . "<br>";
print $row['description'] . "<br>";
print $row['hours'] . " hrs.<br>";
print $row['semester'] . "<br>";
print $row['year'] . "<br>";
}
}
else
echo 'Could not fetch results.';
unset($pdo);
unset($query);
?>
Current Display
Computer Programming I
CPSC1400
Introduction to disciplined, object-oriented program development.
4 hrs.
0
2013
Desire Display
Computer Programming I
CPSC1400
Introduction to disciplined, object-oriented program development.
4 hrs.
Fall
2013
Lets say I'm running a long worker-script in one of several open interactive rails consoles.
The script is updating columns in a very, very, very large table of records. I've muted the ActiveRecord logger to speed up the process, and instruct the script to output some record of progress so I know how roughly how long the process is going to take. That is what I am currently doing and it would look something like this:
ModelName.all.each_with_index do |r, i|
puts i if i % 250
...runs some process...
r.save
end
Sometimes its two nested arrays running, such that there would be multiple iterators and other things running all at once.
Is there a way that I could do something like this and access that variable from a separate rails console? (such that the variable would be overwritten every time the process is run without much slowdown)
records = ModelName.all
$total = records.count
records.each_with_index do |r, i|
$i = i
...runs some process...
r.save
end
meanwhile mid-process in other console
puts "#{($i/$total * 100).round(2)}% complete"
#=> 67.43% complete
I know passing global variables from one separate instance of ruby to the next doesn't work. I also just tried this to no effect as well
unix console 1
$X=5
echo {$X}
#=> 5
unix console 2
echo {$X}
#=> ""
Lastly, I also know using global variables like this is a major software design pattern no-no. I think that's reasonable, but I'd still like to know how to break that rule if I'd like.
Writing to a text file obviously would work. So would writing to a separate database table or something. That's not a bad idea. But the really cool trick would be sharing a variable between two instances without writing to a text file or database column.
What would this be called anyway? Tunneling? I don't quite know how to tag this question. Maybe bad-idea is one of them. But honestly design-patterns isn't what this question is about.
pass=session("password")
Set objIns=server.CreateObject("adodb.connection")
objIns.Open session("Psrconnect")
inspass="Insert into passwords(pass) values ('&pass&')"
objIns.Execute(inspass)
i dont know what should be the syntax to pass the value stored in the variable. with this syntax, the value entered in the database is &pass&.
can anyone plz help me out?
I am using C# code for inserting record and datetimepicker control for Date
I want to insert Date like 24-05-2010 in MySQL Database
What Datatype i have to use for that in MySQL table
and how to right insert query for to insert date?
My database has around 25 core numbers, in that weekly basis I need to create an index and drop index. While creating the index it takes long time to complete, my log file also keeps on increasing, and when I delete some numbers from that table also taking too much time (because weekly basis I have to delete 30 to 50 lack numbers and add 30 to 40 lack new number also).
Can u please give me the proper solution..