8 Replies - 1321 Views - Last Post: 10 April 2012 - 08:33 AM Rate Topic: -----

#1 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 06:38 AM

ok so i have an SQL query. but i want to put null where there is no data how do i do this.
Is This A Good Question/Topic? 0
  • +

Replies To: how do i put null in the SQL query where there is no data?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 06:45 AM

First your column needs allow nulls.

Then you just do something like:

update <table name>
set
<column name> = null
where <condition>



What does your query look like?
Was This Post Helpful? 0
  • +
  • -

#3 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:05 AM

SELECT *
FROM bands
left join band_members
on band_members.band_id = bands.band_id

what is my table name. as it's a query.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:10 AM

Oh.. you are doing a join? Well that's a bit different. Left join should provide nulls where there is data in the left table and not in the right.

Where do you exactly want the nulls to be?
Was This Post Helpful? 0
  • +
  • -

#5 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:17 AM

i want the nulls to be where there is no data... right now they are just blank.

my assignment question is: Use a left outer join to list all band_ids, band_names and their members details. If they have no members listed in the band_members relation then the band_id and band_name
should still be listed but with null values for the band members details.

"null values" does that mean if there is no data then "null" should be displayed.
or does it mean blank space.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:26 AM

What database are you using? MSSQL should provide nulls in the cells that don't have matching data.
Was This Post Helpful? 0
  • +
  • -

#7 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:27 AM

i am using SQLite database browser
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:31 AM

That makes some sense. SQLlite tends to show, what everyone else would call a null, as a blank space.
Was This Post Helpful? 0
  • +
  • -

#9 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

Re: how do i put null in the SQL query where there is no data?

Posted 10 April 2012 - 08:33 AM

lol so i have answered the questions... thanks guys!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1