Archive for the ‘Mysql Stuff’ Category

DELETE Main, Trans
FROM Main
INNER JOIN Trans
WHERE Main.Id = Trans.F_Main
AND Main.F_Sess=’6′

Advertisements

Use of Variable in sql query

Posted: August 6, 2010 in Mysql Stuff

select @a:=stuid from student_master where enrollno = ‘834’;

select * from student_trans where stuid =@a and sessid=’7′ and currentclass=’1′;

select * from bill_master where F_student_master = @a and F_sessions =’7′;

select * from receipt_main where F_student_master = @a and F_Sessions=’7′;

select stud_id , group_concat(paper_id) as i from tb
group by id

Original Table:
stud_id paper_id
1 1
1 2
1 3
1 4
2 2
2 3
3 1
4 2

Output:
stud_id paper_id
1 1,2,3,4
2 2,3
3 1
4 2

Confused by heading??? Yep, it’s true now LAMP become more powerful,it got wings of Sun

sun_mysql1.gif

Sunmicrosystems accounced that company is going to accuire open source database giant Mysql, (that forms M of LAMP). Deal is settaled in $1 Billion in cash and assumed stock options.

MySQL is used by many of the web’s largest companies, including YouTube, Facebook, and Wikipedia. and this is one of the most popular open source web development stacks utilized by web sites today.

You can see found details about this news here on Sun Microsystems News Center

Normally we store data cobine values in different fields in database like First Name, Middle Name, Last Name. But while retriving data usually we wan’t to display data as a single string like display First Name, Middle Name, Last Name as a single string “User Name”.

To achive this output we concatinate all these sub values, some thing like this in PHP (more…)

By default Mysql store and returen ‘date’ data type values in “YYYY/MM/DD” format. So if we want to display date in different format then we have to format date values as per our requirement in scripting language.

Like in PHP if i want to display Date of Birth of student in “DD/MM/YYYY” format then i have to do something like this – (more…)