/    Sign up×
Community /Pin to ProfileBookmark

Mysql Select problem

hi there
How can select one field according to other field.
for ex i have table like below

[code=php]id name title active passive
1 tUTOR jsp active
2 tutorial PHP passive
3 tutorial PHP active
4 tutorial PHP active [/code]

here i would like to choose only PHP with active fields
Thanks for attention

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 19.2010 — SELECT <span><code>title</code></span> FROM <span><code>table_name</code></span> WHERE <span><code>active</code></span> = 'active'
(If desired, you could change that to [b]SELECT DISTINCT[/b] to consolidate duplicate title values.)
Copy linkTweet thisAlerts:
@azegurbauthorMar 19.2010 — you know there is two option in PHP one is active other is passive

i would like to choose php option with active ones

thanks for attention
Copy linkTweet thisAlerts:
@NogDogMar 19.2010 — Not sure what the question is, then. The only difference in the last two rows is the [b]id[/b] value. If you want that, then add it to the selection list:
<i>
</i>SELECT <span><code>id</code></span>, <span><code>title</code></span> FROM <span><code>table_name</code></span> WHERE <span><code>active</code></span> = 'active'

-- or --

SELECT <span><code>id</code></span>, <span><code>name</code></span>, <span><code>title</code></span> FROM <span><code>table_name</code></span> WHERE <span><code>active</code></span> = 'active'


If that's not the answer, then I guess I need a better question. ?
Copy linkTweet thisAlerts:
@azegurbauthorMar 19.2010 — Thank you for your attention
Copy linkTweet thisAlerts:
@tirnaMar 19.2010 — you know there is two option in PHP one is active other is passive

i would like to choose php option with active ones

thanks for attention [/QUOTE]


Maybe try this:

[CODE]select * from tblTableName where title= 'PHP' and active = 'active';[/CODE]
Copy linkTweet thisAlerts:
@azegurbauthorMar 20.2010 — That works fine

Thanks thanks very much
×

Success!

Help @azegurb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...