i have an exel file. i want to change this file into mdf formmat. Plz tell me the full procedure, how i can convert this file. i m using excel 2003 nd sql server 2000.
I am trying to count across 2 tables and I dont see whats wrong with my query yet I get a wrong result. User 2 does not exist in table_two, so the zero is correct.
SELECT t1.creator_user_id, COUNT(t1.creator_user_id), COUNT(t2.user_id)
FROM table_one AS t1
LEFT JOIN table_two AS t2 ON t2.user_id = t1.creator_user_id
GROUP BY t1.creator_user_id, t2.user_id
Actual result
1 192 192
2 9 0
Expected result
1 16 12
2 9 0
The result indicate a missing group by condition, but I already got both fields used.
Where am I wrong ?
Also, can I sum up all users that doesnt exist in table_two for t1 ?
Like user 3 exists 21 times in t1, then the results would be:
1 16 12 (users with > 0 in t2 will need their own row)
2 30 0 (user 2=9 + user 3=21 => 30)
Its okay for the user Id to be wrong for sum of t1 for all users with 0 in t2. If not possible, then I'll just do two queries.
I'm trying to use concat on some variables. These variables have been declared as chars:
declare v_order_date char(10);
declare v_quantity char(11);
declare v_plant char(100);
I have a cursor where I am setting these as some outputs. To call the results, I am setting v_msg as
set v_msg := concat( v_msg, '\n', v_order_date, v_quantity, v_plant);
However, the result I am getting when I select v_msg is:
2012-01-222501008 Creeping Buttercup
but I want to maintain the length of the declared variables in my select that looks like this
2012-01-22 250 1008 Creeping Buttercup
Are there any suggestions? Thank you.
I want to subtract a amount from a table's field in Zend Framework. I can run it with SQL using following query:
UPDATE `Person` SET credit=credit-50 where id=1
But how to write above SQL query in Zend Framework?
If SELECT SUM(amount) FROM transactions ORDER BY order LIMIT 0, 50 sums the amount field for the first 50 records in a table, how do a sum all records after the first 50? In other words, I'd like to do something like SELECT SUM(amount) from transactions ORDER BY order LIMIT 50, *, but that doesn't work.
my aim is to submit a button id using jquery into a database im only interested in the button not its value.
$("#button").click(function(){
var p = $(this).attr("id");
$.ajax({
type: "POST",
url: subpage.php",
data: 'b='+p,
cache: false,
success: function(html)
{
//process live
}
});
return false;
});
subpage.php
$item = $_POST['b'];
$query = mysql_query("SELECT * FROM table WHERE id = '25' AND bttnid = '$item'");
if(count($query)==0){
mysql_query("INSERT INTO table VALUES ('','25','$item') ");
}
it doesn't submit. please assit
Hi, I have a script which captures tweets and puts them into a database. I will be running the script on a cronjob and then displaying the tweets on my site from the database to prevent hitting the limit on the twitter API.
So I don't want to have duplicate tweets in my database, I understand I can use 'INSERT...ON DUPLICATE KEY UPDATE' to achieve this, but I don't quite understand how to use it.
My database structure is as follows.
Table - Hash
id (auto_increment)
tweet
user
user_url
And currently my SQL to insert is as follows:
$tweet = $clean_content[0];
$user_url = $clean_uri[0];
$user = $clean_name[0];
$query='INSERT INTO hash (tweet, user, user_url) VALUES ("'.$tweet.'", "'.$user.'", "'.$user_url.'")';
mysql_query($query);
How would I correctly use 'INSERT...ON DUPLICATE KEY UPDATE' to insert only if it doesn't exist, and update if it does?
Thanks
Hi all,
I have this problems. using html and php.
May I know how to do this. I have 2 drop down, eg A and B. Drop down B is depend to the drop down A. Example, A have these options which will be called from dbase(no prob with this, tq) (Jack, Carol), and B wil have options depend on A: if select Jack(T1, T2, T3), if select carol(T1,T2,T3,T4,T5).
Here are the sample interface.
Can someone help me with this?
thank you.
Please help I am in major trouble with our production database. I had accidentally inserted a key with a very large value into an autoincrement column, and now I can't seem to change this value without a huge rebuild time.
"ALTER TABLE tracks_copy AUTO_INCREMENT = 661482981"
Is super-slow.
How can I fix this in production? I can't get this to work either (has no effect):
myisamchk tracks.MYI --set-auto-increment=661482982
Any ideas?
Basically, no matter what I do I get an overflow:
SHOW CREATE TABLE tracks
CREATE TABLE tracks (
...
) ENGINE=MYISAM AUTO_INCREMENT=2147483648 DEFAULT CHARSET=latin1
I'm messing around with stored procedures for the first time, but can't even create a simple select! I'm using phpMyAdmin and this is my SQL:
DELIMITER //
CREATE PROCEDURE test_select()
BEGIN
SELECT * FROM products LIMIT 10;
END //
DELIMITER ;
After submitting that, my localhost does some thinking for a loooong time and eventually loads a page with no content called /phpmyadmin/import.php. After reloading phpMyAdmin and trying to invoke the procedure:
CALL test_select();
I get a "PROCEDURE doesn't exist" error. Any ideas?
hi..all..i've a problem i can't connect to database what's wrong with my code?this is my code:
$("#mod").change(function() {
var barcode;
barCode=$("#mod").val();
var data=barCode.split(" ");
$("#mod").val(data[0]);
$("#seri").val(data[1]);
var str=data[0];
var matches=str.match(/(EE|[EJU]).*(D)/i);
$.ajax({
type:"post",
url:"process1.php", data:"value="+matches+"action=tunermatches",
cache:false,
async:false,
success: function(res){
$('#rslt').replaceWith(
"<div id='value'><h6>Tuner range is" + res + " .</h6></div>"
);
}
});
});
and this is my process file:
switch(postVar('action')) {
case 'tunermatches' :
tunermatches(postVar('tuner'));
break;
function tunermatches($tuner)){
$Tuner=mysql_real_escape_string($tuner);
$sql= "SELECT remark FROM settingdata WHERE itemname="Tuner_range" AND itemdata="$Tunermatches";
$res=mysql_query($sql);
$dat=mysql_fetch_array($res,MYSQL_NUM);
if($dat[0]>0) {
echo $dat[0];
}
mysql_close($dbc);
}
OK, Here is what my table looks like
------------------------------------------------
id type
-----------------------------------------------
1 a
2 b
3 a
4 c
5 c
7 a
8 a
------------------------------------------------
Now, I need a query that can give me this output...
-----------------------------------------------------------------
count(*) | count(type=a) | count(type=b) | count(type=c)
-----------------------------------------------------------------
8 4 1 3
------------------------------------------------------------------
I only know to get the total set using count(*), but how to do the remaining
this table i want to create and how assign job to first position???
job_id dynamic
Jobs Title text
Job Description text
Order combo box to choose after what job or at first position in the website
i create this table and cannot choose first job to view in my website
My scenario: There are 3 tables for storing tv show information; season, episode and episode_translation.
My data: There are 3 seasons, with 3 episodes each one, but there is only translation for one episode.
My objetive: I want to get a list of all the seasons and episodes for a show. If there is a translation available in a specified language, show it, otherwise show null.
My attempt to get serie 1 information in language 1:
SELECT
season_number AS season,number AS episode,name
FROM
season NATURAL JOIN episode
NATURAL LEFT JOIN episode_trans
WHERE
id_serie=1 AND
id_lang=1
ORDER BY
season_number,number
result:
+--------+---------+--------------------------------+
| season | episode | name |
+--------+---------+--------------------------------+
| 3 | 3 | Episode translated into lang 1 |
+--------+---------+--------------------------------+
expected result
+-----------------+--------------------------------+
| season | episode| name |
+-----------------+--------------------------------+
| 1 | 1 | NULL |
| 1 | 2 | NULL |
| 1 | 3 | NULL |
| 2 | 1 | NULL |
| 2 | 2 | NULL |
| 2 | 3 | NULL |
| 3 | 1 | NULL |
| 3 | 2 | NULL |
| 3 | 3 | Episode translated into lang 1 |
+--------+--------+--------------------------------+
Full DB dump
http://pastebin.com/Y8yXNHrH
Hi folks,
I have some PHP code which allows me to sort a column into ascending and descending order (upon click of a table row title), which is good. It works perfectly for my D.O.B colum (with date/time field type), but not for a quantity column.
For example, I have quantites of 10, 50, 100, 30 and another 100.
The order seems to be only appreciating the 1st integer, so my sorting of the column ends up in this order: 10, 100, 100, 30, 50... and 50, 30, 100, 100, 10.
This is obviously incorrect as 100 is bigger than 50, therefore both 100 values should appear at the end surely? It seems to me that 100 is only being taken into account as having the '1' value, then it appears before 10 because the system recognises it has another 0.
Is this normal to happen? Is there any way I can solve this problem? Thanks for any help. P.S. I can show code if necessary, but would like to know if this is a common issue by default.
Hello all,
I am creating a social bookmarking app. I am having a re-thought of the DB design in the middle of development.
Should I normalise the bookmarks table and remove the tag columns that I have into a separate table. I have 10 tags per bookmark and therefore 10 columns per record (per bookmark).
It seems to me that breaking the table into two would just mean I would have to do a join but the way I currently have it, its a straight select - but the table doesn't feel right...?
Thanks all
I got stuck again. Can't overcome this step: loop through (in a form of checkboxes) pallets based on the lot drop down list selection, so it can be further submitted to complete the table. Please, please help.
So, basically, first submit button (drop down menu) brings into the table lot number and description and also checkboxes to choose pallets.
Second submit button (checboxes) brings into the table pallets numbers and weights.
Thank you for any help.
<?php
mysql_connect('localhost','user','');
mysql_select_db('base');
$query="SELECT DISTINCT lot_number FROM pl_table";
$result=mysql_query($query);
?>
<form action="" method="POST">
<select name="option_chosen">
<option>-- Select lot --</option>
<?php
while(list($lot_number)=mysql_fetch_row($result)) {
echo "<option value=\"".$lot_number."\">".$lot_number."</option>";
}
?>
</select>
<input type='submit' name='submitLot' value='Submit' />
</form>
<!-- need help here
<h4>-- Select pallets --</h4>
<form action="" method="POST">
<input type='submit' name='submitPal' value='Submit'/>
</form>
-->
<table border="1" id="table">
<tr>
<th width=80 height=30>Lot<br/>number</th>
<th width=110 height=30>Description</th>
<th width=90 height=30>Pallet<br/>number</th>
<th width=60 height=30>Net</th>
<th width=60 height=30>Gross</th>
</tr>
<?php
if($_SERVER['REQUEST_METHOD'] =='POST')
{$option_chosen=$_POST['option_chosen'];
$query="SELECT * FROM pl_table WHERE lot_number='$option_chosen'";
$run=mysql_query($query);
$row=mysql_fetch_array($run, MYSQLI_ASSOC);
echo "<tr><td>".''."</td>";
echo "<td rowspan='5'>".$row['descr']."</td>";
echo "<td><b>".'Total weight'."<b></td>";
echo "<td>".''."</td><td>".''."</td></tr>";
echo "<td>".$row['lot_number']."</td>";
echo "<td colspan='3'>".''."</td>";
//This to be echoed when "select pallets" submited
//echo "<tr><td>".$row['lot_number']."</td>";
//echo "<td>".$row['pallet_number']."</td>";
//echo "<td>".$row['net']."</td><td>".$row['gross']."</td></tr>";
}
?>
</table>
the table
+--------------------------+-------------------------+---------+-------+
| id | lot_number | descr | pallet_number | net | gross |
+--------------------------+-------------------------+---------+-------+
| 1 | 111 | black | 1 | 800 | 900 |
| 2 | 111 | black | 2 | 801 | 901 |
| 3 | 111 | black | 3 | 802 | 902 |
| 4 | 222 | white | 1 | 800 | 900 |
| 5 | 222 | white | 2 | 801 | 901 |
| 6 | 222 | white | 3 | 802 | 902 |
+--------------------------+-------------------------+---------+-------+
I have to get the median, mode and range of test scores from one column in a table but I am unsure how to go about doing that. When you connect to the database using java, you are normally returned a ResultSet that you can make a table or something out of but how do you get particular numbers or digits? Is there an SQL command to get the median/mode/range or will I have to calculate this myself, and how do you pull out numbers from the table in order to be able to calculate the mode/median/range?
Thanks.
I'm trying to make a very basic php ORM as for a school project. I have got almost everything working, but I'm trying to map results to an array. Here's a snippet of code to hopefully assist my explanation.
$results = array();
foreach($this->columns as $column){
$current = array();
while($row = mysql_fetch_array($this->results)){
$current[] = $row[$column];
print_r($current);
echo '<br><br>';
}
$results[$column] = $current;
}
print_r($results);
return mysql_fetch_array($this->results);
This works, but the while loop only works on the first column. The print_r($results); shows the following:
Array ( [testID] => Array ( [0] => 1 [1] => 2 ) [testName] => Array ( ) [testData] => Array ( ) )
Can anybody shed some light?
Thanks in advance!
I have one table, which has three fields and data.
Name , Top , Total
cat , 1 , 10
dog , 2 , 7
cat , 3 , 20
horse , 4 , 4
cat , 5 , 10
dog , 6 , 9
I want to select the record which has highest value of Total for each Name, so my result should be like this:
Name , Top , Total
cat , 3 , 20
horse , 4 , 4
Dog , 6 , 9
I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?
I'm developing an iPad app that needs read-only access to an Oracle database.
Is there any way to do this? As far as I can see, the only options are using OCI, which requires a prebuilt binary in the form of the instant client (and not built for ARM), or OJDBC drivers. Both of these seem to be out of the question.
In my research I have discovered that libmysqlclient compiles for arm with minimal tuning. This is a stretch, but is there any possible way to use this to my advantage?
I have seen this product providing odbc connectivity through the use of a Windows gateway machine using the ODBC client libraries, but this solution really isn't an option for me at the present time.
Any ideas?
I need some help formulating a select statement. I need to select the total quantity shipped for each part with a distinct color. So the result should be a row with the color name and the total.
Here's my schema:
create table s
( sno char(5) not null,
sname char(20) not null,
status smallint,
city char(15),
primary key (sno)
);
create table p
( pno char(6) not null,
pname char(20) not null,
color char(6),
weight smallint,
city char(15),
primary key (pno)
);
create table sp
( sno char(5) not null,
pno char(6) not null,
qty integer not null,
primary key (sno, pno)
);
I've tried to find the answer to this question but none of the answers fit.
I have two databases, one has 15.000.000 entries and I want to extract the necessary data and store it in a much smaller database with around 33.000 entries. Both databases are open at the same time. Or at least they should be.
While having the big database open and extracting the entries from it, is it possible to check whether the value already exists in the smaller database? I just need some generic way which checks that.