Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MySQL


Advertisements:




SuperbHosting.net & Arvixe.com have generously sponsored dedicated servers and web hosting to ensure a reliable and scalable dedicated hosting solution for BigResource.com.







How To Concatenate Two Fields Values


I know with ms server the below is possible but I have been trying the same with mysql it complains about the two fields I am trying to sum up .

select t1 + t2 , t3 as TotalAccumulated
from T

and again, is it possible to have a set default values as something like this

create table t
Id int,
t1 varchar(10),
t2 varchar(30)'
t4 varchar (40) default (t1 + t3) taking the above two values


View 13 Replies (Posted: December 22, 2008 04:44AM)

Sponsored Links:

Related Forum Messages for MySQL:
Concatenate 2 Fields Into 1?
I have taken over a website from another development company and I want to tidy up the database a bit and would like to do the following.

The current "users" table has the following 2 fields:

firstName
lastName

I would like to create a new field called

name

And to populate this field by concatenating all the first names with the lastnames. I can't do it manually as there are over 16,000 users in the database.

Posted: Jun 18, 2010, 02:09

View 4 Replies!   View Related
Concatenate More Than 2 Fields With Db?
I am trying to use CONCAT with SQL to concatenate 3 fields, and get the following error:

Incorrect parameters in the call to native function 'CONCAT'

The query is as follows

SELECT CONCAT(guests.lastname,', ',guests.firstname', ',guests.passport) AS display
FROM guests
WHERE guests.uuid = '1'

How do you concatenate more than 2 fields in SQL?

Posted: Jul 5 10 at 22:53

View 1 Replies!   View Related
Concatenate Several Fields Into One With Db?
i have three tables tag, page, pagetag With the next data

page
ID NAME
1 page 1
2 page 2
3 page 3
4 page 4......

Posted: Sep 1 08 at 10:16

View 8 Replies!   View Related
Concatenate Address Fields
I've tried to use concat() to concat address fields into one string, but I'm struggling with the commas etc.

My fields are:

address_line1
address_line2
city
state
postal_code
country

For example,

address_line1: 21 Ocean Parade
address_line2: [Null]
city: Seaview
state: CA
postal_code: 90069
country: [Null]

I'd like it to end up as: '21 Ocean Parade, Seaview, CA 90069'

Posted: August 22, 2008 11:07PM

View 7 Replies!   View Related
Concatenate Two Fields In Different Tables?
It can be concatenate fields in a table. But I want to know if you can concatenate two fields where "a" is in categories table and the "other" is in the products table, bone in different tables with mysql.

Posted: Aug 25 10 at 20:11

View 1 Replies!   View Related
Select Concatenate 2 Values With 1 Id?
for example, I have a table 'Map':

Map:

id | place
1 | a
1 | b
2 | a
2 | b
2 | c

What MySQL query can I use for me to have the following results:

id | place
1 | a,b
2 | a,b,c

Posted: Feb 26 at 18:12

View 1 Replies!   View Related
Concatenate Values From Db SELECT?
Let's say I have

SELECT name
FROM table

which gives me something like

foo
bar
baz

and I need to join all the values, to make it into one string like

foo bar baz

so I guess it would be something like

foreach row in (select ...)
var += row

but I have absolutely no idea how to write it in MySQL.

Posted: Jul 7 09 at 11:11

View 1 Replies!   View Related
Concatenate Values Of A Column If The Other Columns Have The Same Value
I have a query

SELECT
cc.contact_id,
cc.name,
ct.name AS contact_type
FROM
contacts AS c
LEFT JOIN contact_companies AS cc ON c.contact_id = cc.contact_id
LEFT JOIN contacts_to_types AS ctt ON cc.contact_id = ctt.contact_id
LEFT JOIN contact_types AS ct ON ctt.contact_type_id = ct.contact_type_id
WHERE
cc.name LIKE '%p%'
ORDER BY name, contact_id

which returns:.......................

Posted: Feb 13 at 16:15

View 1 Replies!   View Related
Concatenate Rows And Then Get Distinct Values?
I have the following columns in my table: alias, first, last. I would like to concatenate the rows & then search for distinct values:
i.e.

jimmyWho, Jim, Smith
BallyHo, Bob, Smith
JimmytwoShoes, Jim, Smith
Bobtastic, Bob, Johnson
JimmytwoShoes, Jim, Smith
BallyHo, Dave, Jones

I would like to have the following results (notice that #5 above is a duplicate):

jimmyWho, Jim, Smith
BallyHo, Bob, Smith
JimmytwoShoes, Jim, Smith
Bobtastic, Bob, Johnson
BallyHo, Dave, Jones

In other words, I need to concatenate the rows & then search for distinct values only AFTER I've concatenated...doing so b/f the concatenation would not give the desired results. Is there a way to do this in Mysql?

Posted: Oct 3 10 at 1:28

View 3 Replies!   View Related
How Does One Concatenate Database Values Into A String
I would like to string together database values into a string. Something like $a "text" $b.
And then use the entire string as a variable, let's say $c.

Is it better to do this at the database level? Will php use lots of resources to do this?

Posted: Apr 18 10 at 18:45

View 4 Replies!   View Related
Php - Updating Different Fields Based On Whether Or Not Other Fields Have Values?
The query below works just fine. I would like it to do the following:

Update flag1 = '$uflag' only if flag1 is empty.
Update flag2 = '$uflag' only if flag1 had a value in it and flag2 is empty.
Update flag3 = '$uflag' only if flag1 and flag2 have values in them and flag3 is empty.

How could I do this?

UPDATE submission SET votes_up = $votes_up, flag1 = '$uflag' WHERE submissionid = $id

Posted: Nov 16 10 at 18:03

View 2 Replies!   View Related
Taking Values From Fields?
there is two table

first table is pg_vendor_signup

pg_vendor_signup
id
vendor_id
name
country_id

secound table is pg_vendor_friends

vid
fid

status pg_vendor_signup contain datais

1
3
ramu
381
2
4
raj
381......

i Want get all name where country id=381 and in pg_vendor_friends get status of table

Posted: Mar 8 10 at 11:57

View 1 Replies!   View Related
Fields Were Values Found?
Suppose you're searching for a specific value in several fields of a table. Is there any wat to know in which fields was the value found?

Example: looking for "AAA" in table "TABLE_A"
SELECT *
FROM TABLE_A
WHERE FieldA LIKE '%AAA%'
OR FieldB LIKE '%AAA%'
OR FieldC LIKE '%AAA%'

I want to know which field contained the value. (and no, I cannot run several queries)

Posted: September 10th, 2010, 06:08 AM

View 4 Replies!   View Related
Set Default Values For Timestamp Fields
what is the syntax for specifying the default values for timestamps in
MySQL in the CREATE TABLE command?

I have 2 timestamps, one for when the record was entered, the other
for any subsequent updates.

I know that the first timestamp column will be set automatically on
updates, but how does the other for creation timestamp get set.

My app is not generating the SQL directly so setting the value using
the NOW() command is not an option, as the inserts are coming from
different timezones I cannot let the clients set their own values.

Posted: July 19th, 2005 11:52 PM

View 6 Replies!   View Related
Use Enum Or Tinyint For Fields Having Values 1 And 0?
I use tinyint (1) for fields which contain either 1 or 0, for xample, is_active. I can use enum ('1','0') instead but not sure which cases I should use enum or tinyint.

Posted: Jul 5 10 at 8:58

View 6 Replies!   View Related
Search Using 2 Tables: Fields And Values?
I'm trying to make a custom search for my site using the two tables I have (inherited from drupal): profile_fields and profile_values. The goal is to have returned a list of unique UID's for users that fit the search criteria.

I'm trying things like:

Code:

SELECT DISTINCT v.uid FROM profile_values v INNER JOIN profile_fields f ON v.fid = f.fid WHERE (f.name = 'profile_client_status' AND v.value = 'Active') AND (f.name = 'profile_counselor_approval' AND v.value = '1')

But it returns zero results because its looking for a single row with all those conditions, whereas I just need the uid's where there are two rows with those conditions (ie one row where status = active and another where approval = 1) My search form has a lot of criteria, like location, age, etc etc, so I need to be able to handle an arbitrary number of WHERE clauses.

Posted: October 21st, 2010, 05:17 PM

View 2 Replies!   View Related
Create Fields With Multiple Values?
I would like to create a database of music. An album has many values for the fields: mood, style etc. How would I structure my tables for this situation? Is it possible to have a field with many values?

Posted: Jul 10 10

View 2 Replies!   View Related
Select Only Those Rows Which Have More Than One Of Given Fields With Values?
Is there some elegant way to do that, without a big WHERE with lots of AND and OR? For example there are 4 columns: A, B, C, D. For each row the columns have random integer values. I need to select only those rows which have more than one column with a non-zero value. For example (1,2,3,4) and (3,4,0,0) should get selected, however (0,0,7,0) should not be selected (there are no rows that have zeros only).

PS. I know how this looks but the funny thing is that this is not exam or something, it's a real query which I need to use in a real app :D

Posted: Jan 28 at 18:52

View 3 Replies!   View Related
Exclude Results Where Two Fields Are Not Of Certain Values
I have two tables which have some transactional stuff stored in them. There will be many records per user_id in each table. Table1 and Table2 have a one-to-one relationship with each other. I want to pull records from both tables, but I want to exclude records which have certain values in both tables. I don't care if they both don't have these values, or if just one does, but both tables should not have both values. For example:

SELECT t1.id, t1.type, t2.name
FROM table1 t1
INNER JOIN table2 t2 ON table.xid = table2.id
WHERE t1.user_id = 100
AND (t1.type != 'FOO' AND t2.name != 'BAR')

So t1.type is type ENUM with about 10 different options, and t2.name is also type ENUM with 2 options. My expected results would look a little like:

1, FOO, YUM
2, BOO, BAR
3, BOO, YUM

But instead, all I'm getting is:

3, BOO, YUM

It appears to be filtering out all records which has 'FOO' as the type, and 'BAR' as the name.

Posted: Mar 18 10 at 8:57

View 1 Replies!   View Related
Is It Possible To Sum The Values Of Multiple Fields On A Single SQL Record?
I have fields for Goals and Assists.

I want to take those 2 fields and sum them to make a 3rd field PTS, then send them to variable in my PHP code to be printed to the screen.

My statement is this:

SELECT player_stats.G, player_stats.A, SUM (player_stats.G + player_stats.A) PTS
FROM player_stats
WHERE player_stats.PID =10
AND player_stats.season =1

The statement breaks with the bolded part.

Posted: 02-15-2005, 08:50 PM

View 5 Replies!   View Related
Php - Store NULL Values In Datetime Fields?
I have a "bill_date" field that I want to be blank (NULL) until it's been billed, at which point the date will be entered. I see that MySQL does not like NULL values in datetime fields. Do any of you have a simple way to handle this, or am I forced to use the min date as a "NULL equivalent" and then check for that date?

EDITED TO ADD:
I do see that MySQL will accept the NULL value, but it won't accept it as a database update if I'm updating the record using PHP.The variable name is $bill_date but it won't leave the variable as NULL if I update a record without sending a value to $bill_date -- I get this error: Database query failed: Incorrect datetime value: '' for column 'bill_date' at row 1I assume I need to actually send the word NULL, or leave it out of the update query altogether, to avoid this error?

Posted: Nov 6 09 at 23:01

View 3 Replies!   View Related
Database - MySQL Multiple Values In Fields, EAV?
I'm developing a search system for a realty site and it was working well until I realized I had forgotten to take for account that some of my fields (which are used as filters in the search page) could be multiple values. What I mean is that I had only one field for Sale and Rent and one only one field as well for Residential and Commercial (other fields too) -- the problem is that a property could be for sale or rent or could be residential, commercial and industrial.

Posted: Jan 12 at 1:41

View 2 Replies!   View Related
Php - Allowed Values List In Drupal CCK Fields?
I'm basically looking to simply print out each of the allowed values in a CCK field..

i know the allowed values are stored inside a text field within the table: 'content_node_field'.

the values are then stored within 'global_settings'

I'm looking to somehow print out each individual allowed value using a PHP loop.

however with all values being stored within one text field.. im finding it hard to print out each value individually.

Posted: Apr 20 10 at 10:22

View 2 Replies!   View Related
NULL Values - Importing Fields From A Csv File
I am importing fields from a csv file into SQL, and my blank values are being interpreted as 0's rather than nulls. Here is my SHOW CREATE TABLE output:

CREATE TABLE `tbl_user_primary_skills` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`skill_category` int(11) DEFAULT NULL,
`skill_subcategory` int(11) DEFAULT NULL,
`yer_exp` int(11) DEFAULT NULL,
`specialization` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=827 DEFAULT CHARSET=latin1...............

Posted: July 09, 2010 03:32PM

View 7 Replies!   View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved